Skip to main content

Response

Struct Response 

Source
pub struct Response {
Show 33 fields pub background: Option<bool>, pub completed_at: Option<f64>, pub conversation: Option<Conversation2>, pub created_at: f64, pub error: ResponseError, pub id: String, pub incomplete_details: ResponseIncompleteDetails, pub instructions: ResponseInstructions, pub max_output_tokens: Option<i64>, pub max_tool_calls: Option<i64>, pub metadata: Metadata, pub model: ModelIdsResponses, pub object: ResponseObject, pub output: Vec<OutputItem>, pub output_text: Option<String>, pub parallel_tool_calls: bool, pub previous_response_id: Option<String>, pub prompt: Option<Prompt>, pub prompt_cache_key: Option<String>, pub prompt_cache_retention: Option<ResponsePromptCacheRetention>, pub reasoning: Option<Reasoning>, pub safety_identifier: Option<ResponseSafetyIdentifier>, pub service_tier: Option<ServiceTier>, pub status: Option<ResponseStatus>, pub temperature: f64, pub text: Option<ResponseTextParam>, pub tool_choice: ToolChoiceParam, pub tools: ToolsArray, pub top_logprobs: Option<i64>, pub top_p: f64, pub truncation: Option<ResponseTruncation>, pub usage: Option<ResponseUsage>, pub user: Option<String>,
}
Expand description

Response

JSON schema
{
 "title": "The response object",
 "allOf": [
   {
     "$ref": "#/components/schemas/ModelResponseProperties"
   },
   {
     "$ref": "#/components/schemas/ResponseProperties"
   },
   {
     "type": "object",
     "required": [
       "created_at",
       "error",
       "id",
       "incomplete_details",
       "instructions",
       "metadata",
       "model",
       "object",
       "output",
       "parallel_tool_calls",
       "temperature",
       "tool_choice",
       "tools",
       "top_p"
     ],
     "properties": {
       "completed_at": {
         "anyOf": [
           {
             "description": "Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n",
             "type": "number",
             "format": "unixtime"
           }
         ]
       },
       "conversation": {
         "anyOf": [
           {
             "$ref": "#/components/schemas/Conversation-2"
           }
         ]
       },
       "created_at": {
         "description": "Unix timestamp (in seconds) of when this Response was created.\n",
         "type": "number",
         "format": "unixtime"
       },
       "error": {
         "$ref": "#/components/schemas/ResponseError"
       },
       "id": {
         "description": "Unique identifier for this Response.\n",
         "type": "string"
       },
       "incomplete_details": {
         "anyOf": [
           {
             "description": "Details about why the response is incomplete.\n",
             "type": "object",
             "properties": {
               "reason": {
                 "description": "The reason why the response is incomplete.",
                 "type": "string",
                 "enum": [
                   "max_output_tokens",
                   "content_filter"
                 ]
               }
             }
           }
         ]
       },
       "instructions": {
         "anyOf": [
           {
             "description": "A system (or developer) message inserted into the model's context.\n\nWhen using along with `previous_response_id`, the instructions from a previous\nresponse will not be carried over to the next response. This makes it simple\nto swap out system (or developer) messages in new responses.\n",
             "oneOf": [
               {
                 "description": "A text input to the model, equivalent to a text input with the\n`developer` role.\n",
                 "type": "string"
               },
               {
                 "title": "Input item list",
                 "description": "A list of one or many input items to the model, containing\ndifferent content types.\n",
                 "type": "array",
                 "items": {
                   "$ref": "#/components/schemas/InputItem"
                 }
               }
             ]
           }
         ]
       },
       "max_output_tokens": {
         "anyOf": [
           {
             "description": "An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](/docs/guides/reasoning).\n",
             "type": "integer"
           }
         ]
       },
       "object": {
         "description": "The object type of this resource - always set to `response`.\n",
         "type": "string",
         "enum": [
           "response"
         ],
         "x-stainless-const": true
       },
       "output": {
         "description": "An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n  on the model's response.\n- Rather than accessing the first item in the `output` array and\n  assuming it's an `assistant` message with the content generated by\n  the model, you might consider using the `output_text` property where\n  supported in SDKs.\n",
         "type": "array",
         "items": {
           "$ref": "#/components/schemas/OutputItem"
         }
       },
       "output_text": {
         "anyOf": [
           {
             "description": "SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n",
             "type": "string",
             "x-oaiSupportedSDKs": [
               "python",
               "javascript"
             ]
           }
         ]
       },
       "parallel_tool_calls": {
         "description": "Whether to allow the model to run tool calls in parallel.\n",
         "type": "boolean"
       },
       "status": {
         "description": "The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n",
         "type": "string",
         "enum": [
           "completed",
           "failed",
           "in_progress",
           "cancelled",
           "queued",
           "incomplete"
         ]
       },
       "usage": {
         "$ref": "#/components/schemas/ResponseUsage"
       }
     }
   }
 ]
}

Fields§

§background: Option<bool>§completed_at: Option<f64>§conversation: Option<Conversation2>§created_at: f64

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

§error: ResponseError§id: String

Unique identifier for this Response.

§incomplete_details: ResponseIncompleteDetails§instructions: ResponseInstructions§max_output_tokens: Option<i64>§max_tool_calls: Option<i64>§metadata: Metadata§model: ModelIdsResponses§object: ResponseObject

The object type of this resource - always set to response.

§output: Vec<OutputItem>

An array of content items generated by the model.

  • The length and order of items in the output array is dependent on the model’s response.
  • Rather than accessing the first item in the output array and assuming it’s an assistant message with the content generated by the model, you might consider using the output_text property where supported in SDKs.
§output_text: Option<String>§parallel_tool_calls: bool

Whether to allow the model to run tool calls in parallel.

§previous_response_id: Option<String>§prompt: Option<Prompt>§prompt_cache_key: Option<String>

Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the user field. Learn more.

§prompt_cache_retention: Option<ResponsePromptCacheRetention>§reasoning: Option<Reasoning>§safety_identifier: Option<ResponseSafetyIdentifier>

A stable identifier used to help detect users of your application that may be violating OpenAI’s usage policies. The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. Learn more.

§service_tier: Option<ServiceTier>§status: Option<ResponseStatus>

The status of the response generation. One of completed, failed, in_progress, cancelled, queued, or incomplete.

§temperature: f64§text: Option<ResponseTextParam>§tool_choice: ToolChoiceParam§tools: ToolsArray§top_logprobs: Option<i64>§top_p: f64§truncation: Option<ResponseTruncation>§usage: Option<ResponseUsage>§user: Option<String>

This field is being replaced by safety_identifier and prompt_cache_key. Use prompt_cache_key instead to maintain caching optimizations. A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. Learn more.

Trait Implementations§

Source§

impl Clone for Response

Source§

fn clone(&self) -> Response

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 Serialize for Response

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