ResponsesClient Class

  • java.lang.Object
    • com.azure.ai.agents.ResponsesClient

public final class ResponsesClient

Initializes a new instance of the synchronous AgentsClient type.

Method Summary

Modifier and Type Method and Description
com.openai.models.responses.Response createAzureResponse(AzureCreateResponseOptions createResponse, ResponseCreateParams.Builder params)

Creates a response passing additional Azure-specific properties (such as an AgentReference) through the AzureCreateResponseOptions

com.openai.core.http.HttpResponseFor<com.openai.core.http.StreamResponse<com.openai.models.responses.ResponseStreamEvent>> createResponseStreamWithResponse(BinaryData createResponseRequest, RequestOptions requestOptions)

Creates a streaming response from a raw JSON request body and returns the raw HTTP response.

com.openai.core.http.HttpResponseFor<com.openai.models.responses.Response> createResponseWithResponse(BinaryData createResponseRequest, RequestOptions requestOptions)

Creates a response from a raw JSON request body and returns the raw HTTP response.

IterableStream<com.openai.models.responses.ResponseStreamEvent> createStreamingAzureResponse(AzureCreateResponseOptions createResponse, ResponseCreateParams.Builder params)

Creates a streaming response passing additional Azure-specific properties (such as an AgentReference) through the AzureCreateResponseOptions

static AzureCreateResponseDetails getAzureFields(Response response)

Extracts Azure-specific fields from a Response's additional properties.

com.openai.services.blocking.ResponseService getResponseService()

Get the OpenAI client for responses.

Methods inherited from java.lang.Object

Method Details

createAzureResponse

public Response createAzureResponse(AzureCreateResponseOptions createResponse, ResponseCreateParams.Builder params)

Creates a response passing additional Azure-specific properties (such as an AgentReference) through the AzureCreateResponseOptions

Parameters:

createResponse - The Azure-specific create response properties.
params - The parameters to create the response.

Returns:

The created Response.

createResponseStreamWithResponse

public HttpResponseFor<StreamResponse<ResponseStreamEvent>> createResponseStreamWithResponse(BinaryData createResponseRequest, RequestOptions requestOptions)

Creates a streaming response from a raw JSON request body and returns the raw HTTP response.

Delegates to the OpenAI Java SDK's ResponseService.WithRawResponse#createStreaming(ResponseCreateParams, RequestOptions). The createResponseRequest payload is forwarded as the request body (semantically, not byte-for-byte: the JSON is parsed and re-serialized, so property ordering and exact formatting may change and duplicate top-level keys are not preserved).

The returned HttpResponseFor wraps a StreamResponse of ResponseStreamEvent items, which the caller iterates via HttpResponseFor#parse(). The underlying stream must be closed when iteration completes; the typical pattern is try-with-resources on either the HttpResponseFor or the parsed StreamResponse.

Parameters:

createResponseRequest - the JSON body representing the create-response request; must be a JSON object.
requestOptions - optional OpenAI request options; pass null to use the defaults.

Returns:

the raw HTTP response, parseable as a StreamResponse of ResponseStreamEvent.

createResponseWithResponse

public HttpResponseFor<Response> createResponseWithResponse(BinaryData createResponseRequest, RequestOptions requestOptions)

Creates a response from a raw JSON request body and returns the raw HTTP response.

This protocol method delegates to the OpenAI Java SDK's ResponseService.WithRawResponse#create(ResponseCreateParams, RequestOptions). The createResponseRequest payload is forwarded as the request body (semantically, not byte-for-byte: the JSON is parsed and re-serialized via additionalBodyProperties, so property ordering and exact formatting may change and duplicate top-level keys are not preserved), so callers can include Azure-specific extensions (such as AgentReference) without going through the strongly-typed ResponseCreateParams.Builder.

The returned HttpResponseFor exposes the status code, headers, and the raw response stream via body(), or the typed Response via parse(). Only one of body() or parse() may be invoked per response, and the caller must close the response (e.g. via try-with-resources) to release the underlying connection.

Note: the second parameter is the openai-java RequestOptions (not the azure-core type) so that the OpenAI-supported options (timeout, response validation) translate faithfully. Additional headers or query parameters must be supplied via the OpenAI request builder pattern (e.g. by using #createAzureResponse for fully-typed requests).

Parameters:

createResponseRequest - the JSON body representing the create-response request; must be a JSON object.
requestOptions - optional OpenAI request options; pass null to use the defaults.

Returns:

the raw HTTP response, parseable as a Response.

createStreamingAzureResponse

public IterableStream<ResponseStreamEvent> createStreamingAzureResponse(AzureCreateResponseOptions createResponse, ResponseCreateParams.Builder params)

Creates a streaming response passing additional Azure-specific properties (such as an AgentReference) through the AzureCreateResponseOptions

Parameters:

createResponse - The Azure-specific create response properties.
params - The parameters to create the response.

Returns:

An IterableStream of ResponseStreamEvent.

getAzureFields

public static AzureCreateResponseDetails getAzureFields(Response response)

Extracts Azure-specific fields from a Response's additional properties.

Parameters:

response - the OpenAI response.

Returns:

the Azure-specific create response result, or null if not present.

getResponseService

public ResponseService getResponseService()

Get the OpenAI client for responses.

Returns:

the OpenAI response service client.

Applies to