Skip to main content

CompletionResponse

Struct CompletionResponse 

Source
pub struct CompletionResponse {
Show 17 fields pub id: String, pub object: ResponseObject, pub created_at: u64, pub status: ResponseStatus, pub error: Option<ResponseError>, pub incomplete_details: Option<IncompleteDetailsReason>, pub instructions: Option<String>, pub max_output_tokens: Option<u64>, pub model: String, pub provider_reasoning: Option<String>, pub provider_request_id: Option<String>, pub reasoning_metadata: Option<Map<String, Value>>, pub reasoning_context: Option<String>, pub usage: Option<ResponsesUsage>, pub output: Vec<Output>, pub tools: Vec<ResponsesToolDefinition>, pub additional_parameters: AdditionalParameters,
}
Expand description

The standard response format from OpenAI’s Responses API.

Fields§

§id: String

The ID of a completion response.

§object: ResponseObject

The type of the object.

§created_at: u64

The time at which a given response has been created, in seconds from the UNIX epoch (01/01/1970 00:00:00).

§status: ResponseStatus

The status of the response.

§error: Option<ResponseError>

Response error (optional)

§incomplete_details: Option<IncompleteDetailsReason>

Incomplete response details (optional)

§instructions: Option<String>

System prompt/preamble

§max_output_tokens: Option<u64>

The maximum number of tokens the model should output

§model: String

The model name

§provider_reasoning: Option<String>

Provider-specific top-level reasoning content returned by some OpenAI-compatible Responses implementations.

§provider_request_id: Option<String>

The transport request id from the x-request-id response header — not part of the response body; stamped by the request driver, so wire deserialization always leaves it None and the manual Serialize (which mirrors the wire body) never emits it.

§reasoning_metadata: Option<Map<String, Value>>

The complete object-shaped top-level reasoning metadata returned by the provider.

Unknown fields, unknown values, and null-valued members inside the object are preserved value-equivalently. A top-level null, missing field, or unsupported non-object shape is normalized to no reasoning metadata. When serializing manually constructed responses, Self::provider_reasoning takes precedence over this field, and this field takes precedence over Self::reasoning_context.

§reasoning_context: Option<String>

The effective reasoning context returned by OpenAI.

This is populated as a convenience projection of Self::reasoning_metadata. String-shaped reasoning returned by compatible providers remains available through Self::provider_reasoning.

§usage: Option<ResponsesUsage>

Token usage

§output: Vec<Output>

The model output (messages, etc will go here)

§tools: Vec<ResponsesToolDefinition>

Tools

§additional_parameters: AdditionalParameters

Additional parameters

Trait Implementations§

Source§

impl Clone for CompletionResponse

Source§

fn clone(&self) -> CompletionResponse

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 CompletionResponse

Source§

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

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

impl<'de> Deserialize<'de> for CompletionResponse

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 NormalizeCompletionResponse for CompletionResponse

Normalize an OpenAI Responses API completion.

The provider descriptor name is an input rather than a constant: ChatGPT and Copilot return this exact wire shape, so hardcoding "openai" here would mislabel them. Taking it as part of the conversion makes the correct name impossible to forget.

Source§

fn normalize( self, provider: &str, ) -> Result<CompletionResponse, CompletionError>

Normalize this payload, attributing it to provider.
Source§

impl ProviderResponseExt for CompletionResponse

Source§

fn get_response_id(&self) -> Option<String>

The response ID (resp_...), which is deliberately not the assistant message ID (msg_...) that the normalized response carries.

Source§

type Usage = ResponsesUsage

Provider-native usage type.
Source§

fn get_response_model_name(&self) -> Option<String>

Returns the provider response model name, if supplied.
Source§

fn get_text_response(&self) -> Option<String>

Returns the primary text response, when available.
Source§

fn get_usage(&self) -> Option<Self::Usage>

Returns provider-native usage metrics, if supplied.
Source§

impl Serialize for CompletionResponse

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoToolOutput for T
where T: Serialize + 'static,

Source§

fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>

Convert this value without routing structured data through a string.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

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
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