Table of Contents

Class CreateResponseRequest

Namespace
OpenAI.Responses
Assembly
OpenAI-DotNet.dll
public sealed class CreateResponseRequest
Inheritance
CreateResponseRequest
Inherited Members

Constructors

CreateResponseRequest()

public CreateResponseRequest()

CreateResponseRequest(IEnumerable<IResponseItem>, Model, bool?, IEnumerable<string>, string, int?, IReadOnlyDictionary<string, string>, bool?, string, Prompt, Reasoning, string, bool?, double?, TextResponseFormat, JsonSchema, string, IEnumerable<Tool>, double?, Truncation, string)

public CreateResponseRequest(IEnumerable<IResponseItem> input, Model model = null, bool? background = null, IEnumerable<string> include = null, string instructions = null, int? maxOutputTokens = null, IReadOnlyDictionary<string, string> metadata = null, bool? parallelToolCalls = null, string previousResponseId = null, Prompt prompt = null, Reasoning reasoning = null, string serviceTier = null, bool? store = null, double? temperature = null, TextResponseFormat responseFormat = TextResponseFormat.Auto, JsonSchema jsonSchema = null, string toolChoice = null, IEnumerable<Tool> tools = null, double? topP = null, Truncation truncation = Truncation.Auto, string user = null)

Parameters

input IEnumerable<IResponseItem>
model Model
background bool?
include IEnumerable<string>
instructions string
maxOutputTokens int?
metadata IReadOnlyDictionary<string, string>
parallelToolCalls bool?
previousResponseId string
prompt Prompt
reasoning Reasoning
serviceTier string
store bool?
temperature double?
responseFormat TextResponseFormat
jsonSchema JsonSchema
toolChoice string
tools IEnumerable<Tool>
topP double?
truncation Truncation
user string

CreateResponseRequest(string, Model, bool?, IEnumerable<string>, string, int?, IReadOnlyDictionary<string, string>, bool?, string, Prompt, Reasoning, string, bool?, double?, TextResponseFormat, JsonSchema, string, IEnumerable<Tool>, double?, Truncation, string)

public CreateResponseRequest(string textInput, Model model = null, bool? background = null, IEnumerable<string> include = null, string instructions = null, int? maxOutputTokens = null, IReadOnlyDictionary<string, string> metadata = null, bool? parallelToolCalls = null, string previousResponseId = null, Prompt prompt = null, Reasoning reasoning = null, string serviceTier = null, bool? store = null, double? temperature = null, TextResponseFormat responseFormat = TextResponseFormat.Auto, JsonSchema jsonSchema = null, string toolChoice = null, IEnumerable<Tool> tools = null, double? topP = null, Truncation truncation = Truncation.Auto, string user = null)

Parameters

textInput string
model Model
background bool?
include IEnumerable<string>
instructions string
maxOutputTokens int?
metadata IReadOnlyDictionary<string, string>
parallelToolCalls bool?
previousResponseId string
prompt Prompt
reasoning Reasoning
serviceTier string
store bool?
temperature double?
responseFormat TextResponseFormat
jsonSchema JsonSchema
toolChoice string
tools IEnumerable<Tool>
topP double?
truncation Truncation
user string

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?

Include

Specify additional output data to include in the model response.
Currently supported values are:

  • file_search_call.results: Include the search results of the file search tool call.
  • message.input_image.image_url: Include image URLs from the computer call output.
  • computer_call_output.output.image_url: Include image urls from the computer call output.
[JsonInclude]
[JsonPropertyName("include")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyList<string> Include { get; }

Property Value

IReadOnlyList<string>

Input

Text, image, or file inputs to the model, used to generate a response.

[JsonInclude]
[JsonPropertyName("input")]
public IReadOnlyList<IResponseItem> Input { get; }

Property Value

IReadOnlyList<IResponseItem>

Instructions

Inserts a system (or developer) message as the first item in the model's context. When using along with PreviousResponseId, 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)]
public string Instructions { get; }

Property Value

string

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

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

Prompt

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

Property Value

Prompt

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

Property Value

string

Store

Whether to store the generated model response for later retrieval via API.

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

Property Value

bool?

Stream

If set to true, the model response data will be streamed to the client as it is generated using server-sent events.

[JsonInclude]
[JsonPropertyName("stream")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool Stream { get; }

Property Value

bool

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

TextResponseFormatObject

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

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

Operators

implicit operator CreateResponseRequest(string)

public static implicit operator CreateResponseRequest(string textInput)

Parameters

textInput string

Returns

CreateResponseRequest