Table of Contents

Class Response

Namespace
OpenAI.Responses
Assembly
OpenAI-DotNet.dll
public sealed class Response : BaseResponse, IListItem, IServerSentEvent
Inheritance
Response
Implements
Inherited Members
Extension Methods

Properties

Background

Whether to run the model response in the background.

[JsonInclude]
[JsonPropertyName("background")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Background { get; }

Property Value

bool?

CreatedAt

[JsonInclude]
[JsonIgnore]
public DateTime CreatedAt { get; }

Property Value

DateTime

CreatedAtUnixSeconds

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

[JsonInclude]
[JsonPropertyName("created_at")]
public int CreatedAtUnixSeconds { get; }

Property Value

int

Error

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

[JsonInclude]
[JsonPropertyName("error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Error Error { get; }

Property Value

Error

Id

Unique identifier for this Response.

[JsonInclude]
[JsonPropertyName("id")]
public string Id { get; }

Property Value

string

IncompleteDetails

[JsonInclude]
[JsonPropertyName("incomplete_details")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IncompleteDetails IncompleteDetails { get; }

Property Value

IncompleteDetails

Instructions

A system (or developer) message inserted into the model's context. When using along with previous_response_id, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.

[JsonInclude]
[JsonPropertyName("instructions")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[JsonConverter(typeof(StringOrObjectConverter<IReadOnlyList<IResponseItem>>))]
public object Instructions { get; }

Property Value

object

MaxOutputTokens

An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.

[JsonInclude]
[JsonPropertyName("max_output_tokens")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MaxOutputTokens { get; }

Property Value

int?

Metadata

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

[JsonInclude]
[JsonPropertyName("metadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyDictionary<string, string> Metadata { get; }

Property Value

IReadOnlyDictionary<string, string>

Model

Model ID used to generate the response, like gpt-4o or o3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.

[JsonInclude]
[JsonPropertyName("model")]
public string Model { get; }

Property Value

string

Object

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

[JsonInclude]
[JsonPropertyName("object")]
public string Object { get; }

Property Value

string

Output

[JsonInclude]
[JsonPropertyName("output")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyList<IResponseItem> Output { get; }

Property Value

IReadOnlyList<IResponseItem>

OutputText

[JsonInclude]
[JsonPropertyName("output_text")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string OutputText { get; }

Property Value

string

ParallelToolCalls

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

[JsonInclude]
[JsonPropertyName("parallel_tool_calls")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? ParallelToolCalls { get; }

Property Value

bool?

PreviousResponseId

The unique ID of the previous response to the model. Use this to create multi-turn conversations.

[JsonInclude]
[JsonPropertyName("previous_response_id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string PreviousResponseId { get; }

Property Value

string

Reasoning

Configuration options for reasoning models.

[JsonInclude]
[JsonPropertyName("reasoning")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Reasoning Reasoning { get; }

Property Value

Reasoning

Remarks

o-series models only!

ServiceTier

Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:

  • If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted.
  • If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • When not set, the default behavior is 'auto'.
    When this parameter is set, the response body will include the service_tier utilized.
[JsonInclude]
[JsonPropertyName("service_tier")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string ServiceTier { get; set; }

Property Value

string

Status

The status of the response generation.

[JsonInclude]
[JsonPropertyName("status")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ResponseStatus Status { get; }

Property Value

ResponseStatus

Temperature

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
Defaults to 1

[JsonInclude]
[JsonPropertyName("temperature")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Temperature { get; }

Property Value

double?

TextResponseFormat

[JsonIgnore]
public TextResponseFormat TextResponseFormat { get; }

Property Value

TextResponseFormat

TextResponseFormatConfiguration

Configuration options for a text response from the model. Can be plain text or structured JSON data.

[JsonInclude]
[JsonPropertyName("text")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TextResponseFormatObject TextResponseFormatConfiguration { get; }

Property Value

TextResponseFormatObject

ToolChoice

How the model should select which tool (or tools) to use when generating a response. See the tools parameter to see how to specify which tools the model can call.

[JsonInclude]
[JsonPropertyName("tool_choice")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object ToolChoice { get; }

Property Value

object

Tools

A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.

[JsonInclude]
[JsonPropertyName("tools")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyList<ITool> Tools { get; }

Property Value

IReadOnlyList<ITool>

TopP

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
Defaults to 1

[JsonInclude]
[JsonPropertyName("top_p")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? TopP { get; }

Property Value

double?

Truncation

The truncation strategy to use for the model response.

  • Auto: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.
  • Disabled (default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
[JsonInclude]
[JsonPropertyName("truncation")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Truncation Truncation { get; }

Property Value

Truncation

Usage

[JsonInclude]
[JsonPropertyName("usage")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TokenUsage Usage { get; }

Property Value

TokenUsage

User

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.

[JsonInclude]
[JsonPropertyName("user")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string User { get; }

Property Value

string

Methods

PrintUsage()

public void PrintUsage()

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

implicit operator string(Response)

public static implicit operator string(Response response)

Parameters

response Response

Returns

string