pub enum OpenAIContent {
Text(String),
Parts(Vec<OpenAIContentPart>),
}Expand description
OpenAI API message format for serialization.
This struct represents the wire format for messages when communicating
with OpenAI-compatible APIs. It differs from the internal Message
type to accommodate the specific serialization requirements of the
OpenAI API.
§Key Differences from Internal Message Type
- Content is a flat string rather than structured blocks
- Tool calls are represented in OpenAI’s specific format
- Supports both sending tool calls (via
tool_calls) and tool results (viatool_call_id)
§Serialization
Optional fields are skipped when None to keep payloads minimal.
§Usage
This type is typically created by the SDK internally when converting
from Message to API format. Users rarely need to construct these
directly.
§OpenAI Content Format
OpenAI content format supporting both string and array.
For backward compatibility, text-only messages use string format. Messages with images use array format with multiple content parts.
Variants§
Text(String)
Simple text string (backward compatible)
Parts(Vec<OpenAIContentPart>)
Array of content parts (text and/or images)
Trait Implementations§
Source§impl Clone for OpenAIContent
impl Clone for OpenAIContent
Source§fn clone(&self) -> OpenAIContent
fn clone(&self) -> OpenAIContent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenAIContent
impl Debug for OpenAIContent
Source§impl<'de> Deserialize<'de> for OpenAIContent
impl<'de> Deserialize<'de> for OpenAIContent
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for OpenAIContent
impl RefUnwindSafe for OpenAIContent
impl Send for OpenAIContent
impl Sync for OpenAIContent
impl Unpin for OpenAIContent
impl UnwindSafe for OpenAIContent
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
Mutably borrows from an owned value. Read more