pub struct OpenAIModelConfig {
pub model_id: Option<String>,
pub max_tokens: Option<u64>,
pub temperature: Option<f64>,
pub top_p: Option<f64>,
pub context_window_limit: Option<u64>,
pub model_info: Option<ModelInfo>,
pub params: Option<JsonValue>,
pub cache_config: Option<CacheConfig>,
pub frequency_penalty: Option<f64>,
pub presence_penalty: Option<f64>,
pub stateful: Option<bool>,
}Expand description
Configuration of an OpenAIModel (OpenAIModelConfig): the BaseModelConfig fields and
the OpenAI ones, for both APIs.
Fields§
§model_id: Option<String>The model id, such as gpt-5.4, gpt-5.4-mini or gpt-4o. Defaults to gpt-5.4, which
can change between versions.
max_tokens: Option<u64>Maximum tokens to generate (max_completion_tokens on Chat Completions,
max_output_tokens on the Responses API).
temperature: Option<f64>Controls randomness in generation.
top_p: Option<f64>Nucleus sampling.
context_window_limit: Option<u64>Context window size in tokens; filled from the shared model info when unset.
model_info: Option<ModelInfo>Overrides for what the SDK knows about the model.
params: Option<JsonValue>Extra request fields, for parameters without a config field. Built-in Responses tools go
here, before the agent’s tools: {"tools": [{"type": "web_search"}]}. The provider
manages model, messages and stream (Chat Completions) and model, input, stream
and store (Responses); a warning is logged when params holds any of them, and the
provider’s values win. Chat Completions sends stream_options: {"include_usage": true}
unless params sets it, and omits any params key set to null, such as
"stream_options": null for compatible endpoints that reject the field; without
include_usage, the endpoint may not report usage. Must be a JSON object, such as a
json!({..}) literal.
cache_config: Option<CacheConfig>Prompt caching. On the Responses API, models whose model info says they take cache points
(GPT-5.6 and later) cache durable conversation prefixes before temporary context;
messages_ttl: false turns that off. There, a "30m" or "12h" messages_ttl sets each
checkpoint’s ttl, and such a ttl sets prompt_cache_options.ttl. Older models and Chat
Completions cache implicitly. cache_key maps to prompt_cache_key and the retention
literals ("in_memory", "24h") to prompt_cache_retention. Caching fields in params win.
Checkpoints do not remove injected content that a stateful server-side conversation keeps.
frequency_penalty: Option<f64>Reduces repetition of token sequences (-2.0 to 2.0). Chat Completions only.
presence_penalty: Option<f64>Encourages the model to talk about new topics (-2.0 to 2.0). Chat Completions only.
stateful: Option<bool>Whether the server manages conversation state (Responses API only): requests set
store: true and chain turns through previous_response_id, and the agent keeps no local
history. Default false, which sends the whole history on every turn. Set at construction;
OpenAIModel::update_config ignores it with a warning.
Implementations§
Source§impl OpenAIModelConfig
impl OpenAIModelConfig
Sourcepub fn builder() -> OpenAIModelConfigBuilder
pub fn builder() -> OpenAIModelConfigBuilder
Create an instance of OpenAIModelConfig using the builder syntax
Source§impl OpenAIModelConfig
impl OpenAIModelConfig
Sourcepub fn merge(&mut self, update: Self)
pub fn merge(&mut self, update: Self)
Shallow-merges update into self: every field update sets replaces the current value.
Sourcepub fn to_base(&self) -> BaseModelConfig
pub fn to_base(&self) -> BaseModelConfig
The BaseModelConfig fields of this configuration.
Trait Implementations§
Source§impl Clone for OpenAIModelConfig
impl Clone for OpenAIModelConfig
Source§impl Debug for OpenAIModelConfig
impl Debug for OpenAIModelConfig
Source§impl Default for OpenAIModelConfig
impl Default for OpenAIModelConfig
Source§impl From<BaseModelConfig> for OpenAIModelConfig
impl From<BaseModelConfig> for OpenAIModelConfig
Source§fn from(config: BaseModelConfig) -> Self
fn from(config: BaseModelConfig) -> Self
Source§impl From<OpenAIModelConfig> for OpenAIModelOptions
impl From<OpenAIModelConfig> for OpenAIModelOptions
Source§fn from(config: OpenAIModelConfig) -> Self
fn from(config: OpenAIModelConfig) -> Self
Source§impl PartialEq for OpenAIModelConfig
impl PartialEq for OpenAIModelConfig
impl StructuralPartialEq for OpenAIModelConfig
Auto Trait Implementations§
impl Freeze for OpenAIModelConfig
impl RefUnwindSafe for OpenAIModelConfig
impl Send for OpenAIModelConfig
impl Sync for OpenAIModelConfig
impl Unpin for OpenAIModelConfig
impl UnsafeUnpin for OpenAIModelConfig
impl UnwindSafe for OpenAIModelConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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