pub struct MessagesResponse {
pub id: String,
pub type: String,
pub role: Role,
pub content: Vec<ContentBlock>,
pub model: String,
pub stop_reason: Option<StopReason>,
pub stop_sequence: Option<String>,
pub usage: Usage,
}Expand description
Response body for the Messages API.
Fields§
§id: StringUnique object identifier. The format and length of IDs may change over time.
type: StringObject type. For Messages, this is always “message”.
role: RoleConversational role of the generated message. This will always be “assistant”.
content: Vec<ContentBlock>Content generated by the model. This is an array of content blocks, each of which has a type that determines its shape. Currently, the only type in responses is “text”.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]
If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model’s output.
For example, if the input messages were:
[ {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"}, {"role": "assistant", "content": "The best answer is ("} ]
Then the response content might be:
[{"type": "text", "text": "B)"}]
model: StringThe model that handled the request.
stop_reason: Option<StopReason>The reason that we stopped. This may be one the following values:
- “end_turn”: the model reached a natural stopping point
- “max_tokens”: we exceeded the requested max_tokens or the model’s maximum
- “stop_sequence”: one of your provided custom stop_sequences was generated
Note that these values are different than those in /v1/complete, where end_turn and stop_sequence were not differentiated.
In non-streaming mode this value is always non-null. In streaming mode, it is null in the message_start event and non-null otherwise.
stop_sequence: Option<String>Which custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
usage: UsageBilling and rate-limit usage. Anthropic’s API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.
Under the hood, the API transforms requests into a format suitable for the model. The model’s output then goes through a parsing stage before becoming an API response. As a result, the token counts in usage will not match one-to-one with the exact visible content of an API request or response.
For example, output_tokens will be non-zero, even for an empty string response from Claude.
Trait Implementations§
Source§impl Clone for MessagesResponse
impl Clone for MessagesResponse
Source§fn clone(&self) -> MessagesResponse
fn clone(&self) -> MessagesResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessagesResponse
impl Debug for MessagesResponse
Source§impl<'de> Deserialize<'de> for MessagesResponse
impl<'de> Deserialize<'de> for MessagesResponse
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 MessagesResponse
impl PartialEq for MessagesResponse
Source§impl Serialize for MessagesResponse
impl Serialize for MessagesResponse
impl Eq for MessagesResponse
impl StructuralPartialEq for MessagesResponse
Auto Trait Implementations§
impl Freeze for MessagesResponse
impl RefUnwindSafe for MessagesResponse
impl Send for MessagesResponse
impl Sync for MessagesResponse
impl Unpin for MessagesResponse
impl UnwindSafe for MessagesResponse
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.