Class ResponsesEndpoint
OpenAI's most advanced interface for generating model responses. Supports text and image inputs, and text outputs. Create stateful interactions with the model, using the output of previous responses as input. Extend the model's capabilities with built-in tools for file search, web search, computer use, and more. Allow the model access to external systems and data using function calling.
public sealed class ResponsesEndpoint : OpenAIBaseEndpoint- Inheritance
- 
      
      
      ResponsesEndpoint
- Inherited Members
Constructors
ResponsesEndpoint(OpenAIClient)
public ResponsesEndpoint(OpenAIClient client)Parameters
- clientOpenAIClient
Properties
Root
The root endpoint address.
protected override string Root { get; }Property Value
Methods
CancelModelResponsesAsync(string, CancellationToken)
Cancels a model response with the given ID.
public Task<Response> CancelModelResponsesAsync(string responseId, CancellationToken cancellationToken = default)Parameters
- responseIdstring
- The ID of the response to cancel. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
Returns
Remarks
Only responses created with the background parameter set to true can be cancelled.
CreateModelResponseAsync(CreateResponseRequest, Func<IServerSentEvent, Task>, CancellationToken)
Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model's response.
public Task<Response> CreateModelResponseAsync(CreateResponseRequest request, Func<IServerSentEvent, Task> streamEventHandler, CancellationToken cancellationToken = default)Parameters
- requestCreateResponseRequest
- streamEventHandlerFunc<IServerSentEvent, Task>
- Optional, Func<T, TResult> stream callback handler. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
Returns
CreateModelResponseAsync(CreateResponseRequest, Func<string, IServerSentEvent, Task>, CancellationToken)
Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model's response.
public Task<Response> CreateModelResponseAsync(CreateResponseRequest request, Func<string, IServerSentEvent, Task> streamEventHandler = null, CancellationToken cancellationToken = default)Parameters
- requestCreateResponseRequest
- streamEventHandlerFunc<string, IServerSentEvent, Task>
- Optional, Func<T1, T2, TResult> stream callback handler. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
Returns
CreateModelResponseAsync<T>(CreateResponseRequest, Func<IServerSentEvent, Task>, CancellationToken)
Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model's response.
public Task<(T, Response)> CreateModelResponseAsync<T>(CreateResponseRequest request, Func<IServerSentEvent, Task> streamEventHandler, CancellationToken cancellationToken = default)Parameters
- requestCreateResponseRequest
- streamEventHandlerFunc<IServerSentEvent, Task>
- Optional, Func<T, TResult> stream callback handler. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
Returns
Type Parameters
CreateModelResponseAsync<T>(CreateResponseRequest, Func<string, IServerSentEvent, Task>, CancellationToken)
Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model's response.
public Task<(T, Response)> CreateModelResponseAsync<T>(CreateResponseRequest request, Func<string, IServerSentEvent, Task> streamEventHandler = null, CancellationToken cancellationToken = default)Parameters
- requestCreateResponseRequest
- streamEventHandlerFunc<string, IServerSentEvent, Task>
- Optional, Func<T1, T2, TResult> stream callback handler. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
Returns
Type Parameters
DeleteModelResponseAsync(string, CancellationToken)
Deletes a model response with the given ID.
public Task<bool> DeleteModelResponseAsync(string responseId, CancellationToken cancellationToken = default)Parameters
- responseIdstring
- The ID of the response to delete. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
Returns
GetModelResponseAsync(string, CancellationToken, params string[])
Retrieves a model response with the given ID.
public Task<Response> GetModelResponseAsync(string responseId, CancellationToken cancellationToken = default, params string[] include)Parameters
- responseIdstring
- The ID of the response to retrieve. 
- cancellationTokenCancellationToken
- Optional, CancellationToken. 
- includestring[]
- Additional fields to include in the 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.
 
- file_search_call.results: Include the search results of the file search tool call.
Returns
ListInputItemsAsync(string, ListQuery, CancellationToken)
Returns a list of input items for a given response.
public Task<ListResponse<IResponseItem>> ListInputItemsAsync(string responseId, ListQuery query = null, CancellationToken cancellationToken = default)Parameters
- responseIdstring
- The ID of the response to retrieve input items for. 
- queryListQuery
- cancellationTokenCancellationToken
- Optional, CancellationToken.