pub struct CreateMessageRequest {
pub method: String,
pub params: CreateMessageRequestParams,
}Deprecated per SEP-2577 (2026-07-28). Replacement: integrate directly with LLM provider APIs. Earliest removal: first release on/after 2027-07-28.
protocol-2026-07-28 only.Expand description
Complete sampling/createMessage request (matches TypeScript CreateMessageRequest interface).
Deprecated per SEP-2577 โ see module-level docs.
Fieldsยง
ยงmethod: StringDeprecated per SEP-2577 (2026-07-28). Replacement: integrate directly with LLM provider APIs. Earliest removal: first release on/after 2027-07-28.
Method name (always โsampling/createMessageโ)
params: CreateMessageRequestParamsDeprecated per SEP-2577 (2026-07-28). Replacement: integrate directly with LLM provider APIs. Earliest removal: first release on/after 2027-07-28.
Request parameters
Implementationsยง
Sourceยงimpl CreateMessageRequest
impl CreateMessageRequest
Sourcepub fn new(
messages: Vec<SamplingMessage>,
max_tokens: u32,
) -> CreateMessageRequest
Available on crate feature http only.
pub fn new( messages: Vec<SamplingMessage>, max_tokens: u32, ) -> CreateMessageRequest
http only.Creates a sampling/createMessage request from the messages and the maximum number of tokens to sample.
Sourcepub fn with_params(
self,
params: CreateMessageRequestParams,
) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_params( self, params: CreateMessageRequestParams, ) -> CreateMessageRequest
http only.Attaches a fully-constructed params struct.
Sourcepub fn with_model_preferences(
self,
preferences: ModelPreferences,
) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_model_preferences( self, preferences: ModelPreferences, ) -> CreateMessageRequest
http only.Sets the serverโs model preferences on the request parameters.
Sourcepub fn with_system_prompt(
self,
prompt: impl Into<String>,
) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_system_prompt( self, prompt: impl Into<String>, ) -> CreateMessageRequest
http only.Sets the system prompt on the request parameters.
Sourcepub fn with_temperature(self, temperature: f64) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_temperature(self, temperature: f64) -> CreateMessageRequest
http only.Sets the sampling temperature on the request parameters.
Sourcepub fn with_stop_sequences(self, sequences: Vec<String>) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_stop_sequences(self, sequences: Vec<String>) -> CreateMessageRequest
http only.Sets the stop sequences on the request parameters.
Sourcepub fn with_tools(self, tools: Vec<Tool>) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_tools(self, tools: Vec<Tool>) -> CreateMessageRequest
http only.Sets the tools the model may use on the request parameters.
Sourcepub fn with_tool_choice(self, tool_choice: ToolChoice) -> CreateMessageRequest
Available on crate feature http only.
pub fn with_tool_choice(self, tool_choice: ToolChoice) -> CreateMessageRequest
http only.Sets the tool choice on the request parameters.
Trait Implementationsยง
Sourceยงimpl Clone for CreateMessageRequest
impl Clone for CreateMessageRequest
Sourceยงfn clone(&self) -> CreateMessageRequest
fn clone(&self) -> CreateMessageRequest
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl Debug for CreateMessageRequest
impl Debug for CreateMessageRequest
Sourceยงimpl<'de> Deserialize<'de> for CreateMessageRequest
impl<'de> Deserialize<'de> for CreateMessageRequest
Sourceยงfn deserialize<__D>(
__deserializer: __D,
) -> Result<CreateMessageRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CreateMessageRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Sourceยงimpl HasMethod for CreateMessageRequest
impl HasMethod for CreateMessageRequest
Sourceยงimpl HasParams for CreateMessageRequest
impl HasParams for CreateMessageRequest
Sourceยงimpl Serialize for CreateMessageRequest
impl Serialize for CreateMessageRequest
Sourceยงfn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementationsยง
impl Forget for CreateMessageRequest
impl Freeze for CreateMessageRequest
impl Move for CreateMessageRequest
impl RefUnwindSafe for CreateMessageRequest
impl Send for CreateMessageRequest
impl Sync for CreateMessageRequest
impl Unpin for CreateMessageRequest
impl UnsafeUnpin for CreateMessageRequest
impl UnwindSafe for CreateMessageRequest
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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