Package com.azure.ai.inference
Class ChatCompletionsClient
java.lang.Object
com.azure.ai.inference.ChatCompletionsClient
Initializes a new instance of the synchronous ChatCompletionsClient type.
-
Method Summary
Modifier and TypeMethodDescriptioncomplete
(ChatCompletionsOptions options) Gets chat completions for the provided chat messages.Gets completions for the provided input prompt.com.azure.core.util.IterableStream
<StreamingChatCompletionsUpdate> completeStream
(ChatCompletionsOptions options) Gets chat completions for the provided chat messages in streaming mode.com.azure.core.http.rest.Response
<com.azure.core.util.BinaryData> completeWithResponse
(com.azure.core.util.BinaryData completeRequest, com.azure.core.http.rest.RequestOptions requestOptions) Gets chat completions for the provided chat messages.Returns information about the AI model.
-
Method Details
-
completeWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> completeWithResponse(com.azure.core.util.BinaryData completeRequest, com.azure.core.http.rest.RequestOptions requestOptions) Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data. The method makes a REST API call to the `/chat/completions` route on the given endpoint.Header Parameters
Header Parameters Name Type Required Description extra-parameters String No Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. This sets the HTTP request header `extra-parameters`. Allowed values: "error", "drop", "pass-through". RequestOptions.addHeader(java.lang.String, java.lang.String)
Request Body Schema
{ messages (Required): [ (Required){ role: String(system/user/assistant/tool) (Required) } ] frequency_penalty: Double (Optional) stream: Boolean (Optional) presence_penalty: Double (Optional) temperature: Double (Optional) top_p: Double (Optional) max_tokens: Integer (Optional) response_format (Optional): { type: String (Required) } stop (Optional): [ String (Optional) ] tools (Optional): [ (Optional){ type: String (Required) function (Required): { name: String (Required) description: String (Optional) parameters: Object (Optional) } } ] tool_choice: BinaryData (Optional) seed: Long (Optional) model: String (Optional) (Optional): { String: Object (Required) } }
Response Body Schema
{ id: String (Required) created: long (Required) model: String (Required) usage (Required): { completion_tokens: int (Required) prompt_tokens: int (Required) total_tokens: int (Required) } choices (Required): [ (Required){ index: int (Required) finish_reason: String(stop/length/content_filter/tool_calls) (Required) message (Required): { role: String(system/user/assistant/tool) (Required) content: String (Required) tool_calls (Optional): [ (Optional){ id: String (Required) type: String (Required) function (Required): { name: String (Required) arguments: String (Required) } } ] } } ] }
- Parameters:
completeRequest
- The completeRequest parameter.requestOptions
- The options to configure the HTTP request before HTTP client sends it.- Returns:
- chat completions for the provided chat messages.
Completions support a wide variety of tasks and generate text that continues from or "completes"
provided prompt data along with
Response
. - Throws:
com.azure.core.exception.HttpResponseException
- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException
- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException
- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException
- thrown if the request is rejected by server on status code 409.
-
complete
Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data. The method makes a REST API call to the `/chat/completions` route on the given endpoint.- Parameters:
options
- Options for complete API.- Returns:
- chat completions for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException
- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException
- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException
- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException
- thrown if the request is rejected by server on status code 409.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
complete
Gets completions for the provided input prompt. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Parameters:
prompt
- The prompt to generate completion text from.- Returns:
- chat completions for the provided input prompts. Chat completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException
- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException
- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException
- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException
- thrown if the request is rejected by server on status code 409.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
completeStream
public com.azure.core.util.IterableStream<StreamingChatCompletionsUpdate> completeStream(ChatCompletionsOptions options) Gets chat completions for the provided chat messages in streaming mode. Chat completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Parameters:
options
- The configuration information for a chat completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Returns:
- chat completions stream for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException
- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException
- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException
- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException
- thrown if the request is rejected by server on status code 409.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getModelInfo
Returns information about the AI model. The method makes a REST API call to the `/info` route on the given endpoint.- Returns:
- represents some basic information about the AI model.
- Throws:
com.azure.core.exception.HttpResponseException
- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException
- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException
- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException
- thrown if the request is rejected by server on status code 409.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-