Skip to main content

Response

Struct Response 

Source
pub struct Response {
Show 26 fields pub id: String, pub created_at: u64, pub error: Option<ResponseError>, pub incomplete_details: Option<IncompleteDetails>, pub instructions: Option<String>, pub metadata: Option<HashMap<String, String>>, pub model: String, pub object: ResponseObject, pub output: Vec<ResponseOutputItem>, pub parallel_tool_calls: Option<bool>, pub previous_response_id: Option<String>, pub temperature: Option<f32>, pub top_p: Option<f32>, pub store: Option<bool>, pub status: Option<ResponseStatus>, pub usage: Option<ResponseUsage>, pub background: Option<bool>, pub completed_at: Option<u64>, pub max_output_tokens: Option<u32>, pub max_tool_calls: Option<u32>, pub top_logprobs: Option<u32>, pub truncation: Option<Truncation>, pub service_tier: Option<ServiceTier>, pub user: Option<String>, pub safety_identifier: Option<String>, pub prompt_cache_key: Option<String>,
}
Expand description

The response object returned by the Responses API (non-streaming create, the final streaming events, and retrieve).

Fields§

§id: String

Unique identifier for this response.

§created_at: u64

Unix timestamp (in seconds) of when this response was created.

§error: Option<ResponseError>

An error object returned when the model fails to generate a response.

§incomplete_details: Option<IncompleteDetails>

Details about why the response is incomplete, if it is.

§instructions: Option<String>

The system (or developer) message inserted into the model’s context, echoed back when one was supplied.

§metadata: Option<HashMap<String, String>>

Set of key-value pairs attached to the response, echoed back when metadata was supplied in the request.

§model: String

The model that generated the response.

§object: ResponseObject

The object type, which is always response.

§output: Vec<ResponseOutputItem>

The output items generated by the model (messages, reasoning, tool calls, …).

§parallel_tool_calls: Option<bool>

Whether the model ran tool calls in parallel.

§previous_response_id: Option<String>

The unique ID of the previous response this one builds upon, when previous_response_id was used.

§temperature: Option<f32>

The sampling temperature used.

§top_p: Option<f32>

The nucleus sampling threshold used.

§store: Option<bool>

Whether the response is stored for later retrieval.

§status: Option<ResponseStatus>

The status of the response generation.

§usage: Option<ResponseUsage>

Usage statistics for the request.

§background: Option<bool>

Whether the response ran in the background (echo of the request parameter).

§completed_at: Option<u64>

Unix timestamp (in seconds) of when this response completed. Only present when the status is completed.

§max_output_tokens: Option<u32>

Upper bound for the number of tokens that could be generated (echo of the request parameter).

§max_tool_calls: Option<u32>

Maximum number of built-in tool calls processed in this response (echo of the request parameter).

§top_logprobs: Option<u32>

Number of most likely tokens returned at each output position (echo of the request parameter).

§truncation: Option<Truncation>

The truncation strategy used for the response (echo of the request parameter).

§service_tier: Option<ServiceTier>

The service tier actually used to serve the request. May differ from the value requested.

§user: Option<String>

End-user identifier (echo of the request parameter).

§safety_identifier: Option<String>

Stable identifier used for usage-policy violation detection (echo of the request parameter).

§prompt_cache_key: Option<String>

Prompt cache key (echo of the request parameter).

Implementations§

Source§

impl Response

Source

pub fn is_completed(&self) -> bool

Whether this response completed successfully.

Source

pub fn output_text(&self) -> String

Aggregates all output_text content of the output message items into a single string, like the output_text property of the official SDKs. Returns an empty string when there is no text output.

Source

pub fn reasoning_text(&self) -> String

Aggregates the plain-text reasoning content of the output reasoning items into a single string. Returns an empty string when there is no plaintext reasoning content (e.g. when the provider only returns reasoning summaries or encrypted content).

Trait Implementations§

Source§

impl Clone for Response

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Response

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromStr for Response

Source§

type Err = OapiError

The associated error which can be returned from parsing.
Source§

fn from_str(content: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more