Package com.azure.ai.openai
Class OpenAIClient
java.lang.Object
com.azure.ai.openai.OpenAIClient
Initializes a new instance of the synchronous OpenAIClient type.
-
Method Summary
Modifier and TypeMethodDescriptioncancelBatch(String batchId) Gets details for a single batch specified by the given batchID.com.azure.core.http.rest.Response<Batch>cancelBatchWithResponse(String batchId, com.azure.core.http.rest.RequestOptions requestOptions) Gets details for a single batch specified by the given batchID.createBatch(BatchCreateRequest createBatchRequest) Creates and executes a batch from an uploaded file of requests.com.azure.core.http.rest.Response<Batch>createBatchWithResponse(com.azure.core.util.BinaryData createBatchRequest, com.azure.core.http.rest.RequestOptions requestOptions) Creates and executes a batch from an uploaded file of requests.deleteFile(String fileId) Delete a previously uploaded file.com.azure.core.http.rest.Response<FileDeletionStatus>deleteFileWithResponse(String fileId, com.azure.core.http.rest.RequestOptions requestOptions) Delete a previously uploaded file.com.azure.core.util.BinaryDatagenerateSpeechFromText(String deploymentOrModelName, SpeechGenerationOptions speechGenerationOptions) Generates text-to-speech audio from the input text.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>generateSpeechFromTextWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData speechGenerationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Generates text-to-speech audio from the input text.getAudioTranscription(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions) Gets transcribed text and associated metadata from provided spoken audio file data.getAudioTranscriptionAsPlainText(String deploymentOrModelName, AudioTranscriptionOptions audioTranscriptionOptions) Gets transcribed text and associated metadata from provided spoken audio data.getAudioTranscriptionText(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions) Gets transcribed text and associated metadata from provided spoken audio file data.com.azure.core.http.rest.Response<String>getAudioTranscriptionTextWithResponse(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets transcribed text and associated metadata from provided spoken audio file data.com.azure.core.http.rest.Response<AudioTranscription>getAudioTranscriptionWithResponse(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets transcribed text and associated metadata from provided spoken audio file data.getAudioTranslation(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.getAudioTranslationAsPlainText(String deploymentOrModelName, AudioTranslationOptions audioTranslationOptions) Gets English language transcribed text and associated metadata from provided spoken audio data.getAudioTranslationText(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.com.azure.core.http.rest.Response<String>getAudioTranslationTextWithResponse(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.com.azure.core.http.rest.Response<AudioTranslation>getAudioTranslationWithResponse(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.Gets details for a single batch specified by the given batchID.com.azure.core.http.rest.Response<Batch>getBatchWithResponse(String batchId, com.azure.core.http.rest.RequestOptions requestOptions) Gets details for a single batch specified by the given batchID.getChatCompletions(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions) Gets chat completions for the provided chat messages.com.azure.core.util.IterableStream<ChatCompletions>getChatCompletionsStream(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions) Gets chat completions for the provided chat messages in streaming mode.com.azure.core.http.rest.Response<com.azure.core.util.IterableStream<ChatCompletions>>getChatCompletionsStreamWithResponse(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets chat completions for the provided chat messages in streaming mode.com.azure.core.http.rest.Response<ChatCompletions>getChatCompletionsWithResponse(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets chat completions for the provided chat messages.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>getChatCompletionsWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData chatCompletionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets chat completions for the provided chat messages.getCompletions(String deploymentOrModelName, CompletionsOptions completionsOptions) Gets completions for the provided input prompts.getCompletions(String deploymentOrModelName, String prompt) Gets completions for the provided input prompt.com.azure.core.util.IterableStream<Completions>getCompletionsStream(String deploymentOrModelName, CompletionsOptions completionsOptions) Gets completions as a stream for the provided input prompts.com.azure.core.http.rest.Response<Completions>getCompletionsWithResponse(String deploymentOrModelName, CompletionsOptions completionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets completions for the provided input prompts.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>getCompletionsWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData completionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets completions for the provided input prompts.getEmbeddings(String deploymentOrModelName, EmbeddingsOptions embeddingsOptions) Return the embeddings for a given prompt.com.azure.core.http.rest.Response<Embeddings>getEmbeddingsWithResponse(String deploymentOrModelName, EmbeddingsOptions embeddingsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Return the embeddings for a given prompt.com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>getEmbeddingsWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData embeddingsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Return the embeddings for a given prompt.Returns information about a specific file.byte[]getFileContent(String fileId) Returns information about a specific file.com.azure.core.http.rest.Response<byte[]>getFileContentWithResponse(String fileId, com.azure.core.http.rest.RequestOptions requestOptions) Returns information about a specific file.com.azure.core.http.rest.Response<OpenAIFile>getFileWithResponse(String fileId, com.azure.core.http.rest.RequestOptions requestOptions) Returns information about a specific file.getImageGenerations(String deploymentOrModelName, ImageGenerationOptions imageGenerationOptions) Creates an image given a prompt.com.azure.core.http.rest.Response<ImageGenerations>getImageGenerationsWithResponse(String deploymentOrModelName, ImageGenerationOptions imageGenerationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Creates an image given a prompt.Gets a list of all batches owned by the Azure OpenAI resource.listBatches(String after, Integer limit) Gets a list of all batches owned by the Azure OpenAI resource.com.azure.core.http.rest.Response<PageableList<Batch>>listBatchesWithResponse(com.azure.core.http.rest.RequestOptions requestOptions) Gets a list of all batches owned by the Azure OpenAI resource.Gets a list of previously uploaded files.listFiles(FilePurpose purpose) Gets a list of previously uploaded files.com.azure.core.http.rest.Response<List<OpenAIFile>>listFilesWithResponse(com.azure.core.http.rest.RequestOptions requestOptions) Gets a list of previously uploaded files.uploadFile(FileDetails file, FilePurpose purpose) Uploads a file for use by other operations.
-
Method Details
-
getEmbeddingsWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getEmbeddingsWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData embeddingsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Return the embeddings for a given prompt.Request Body Schema
{ user: String (Optional) model: String (Optional) input (Required): [ String (Required) ] }Response Body Schema
{ data (Required): [ (Required){ embedding (Required): [ double (Required) ] index: int (Required) } ] usage (Required): { prompt_tokens: int (Required) total_tokens: int (Required) } }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.embeddingsOptions- The configuration information for an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- representation of the response data from an embeddings request. Embeddings measure the relatedness of
text strings and are commonly used for search, clustering, recommendations, and other similar scenarios 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.
-
getCompletionsWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getCompletionsWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData completionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets completions for the provided input prompts. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.Request Body Schema
{ prompt (Required): [ String (Required) ] max_tokens: Integer (Optional) temperature: Double (Optional) top_p: Double (Optional) logit_bias (Optional): { String: int (Optional) } user: String (Optional) n: Integer (Optional) logprobs: Integer (Optional) echo: Boolean (Optional) stop (Optional): [ String (Optional) ] presence_penalty: Double (Optional) frequency_penalty: Double (Optional) best_of: Integer (Optional) stream: Boolean (Optional) model: String (Optional) }Response Body Schema
{ id: String (Required) created: int (Required) choices (Required): [ (Required){ text: String (Required) index: int (Required) logprobs (Required): { tokens (Required): [ String (Required) ] token_logprobs (Required): [ double (Required) ] top_logprobs (Required): [ (Required){ String: double (Required) } ] text_offset (Required): [ int (Required) ] } finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) } ] usage (Required): { completion_tokens: int (Required) prompt_tokens: int (Required) total_tokens: int (Required) } }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.completionsOptions- The configuration information for a completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- completions for the provided input prompts. 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.
-
getChatCompletionsWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getChatCompletionsWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData chatCompletionsOptions, 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.Request Body Schema
{ messages (Required): [ (Required){ role: String(system/assistant/user) (Required) content: String (Optional) } ] max_tokens: Integer (Optional) temperature: Double (Optional) top_p: Double (Optional) logit_bias (Optional): { String: int (Optional) } user: String (Optional) n: Integer (Optional) stop (Optional): [ String (Optional) ] presence_penalty: Double (Optional) frequency_penalty: Double (Optional) stream: Boolean (Optional) model: String (Optional) }Response Body Schema
{ id: String (Required) created: int (Required) choices (Required): [ (Required){ message (Optional): { role: String(system/assistant/user) (Required) content: String (Optional) } index: int (Required) finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) delta (Optional): { role: String(system/assistant/user) (Optional) content: String (Optional) } } ] usage (Required): { completion_tokens: int (Required) prompt_tokens: int (Required) total_tokens: int (Required) } }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.chatCompletionsOptions- 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.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.
-
getEmbeddingsWithResponse
public com.azure.core.http.rest.Response<Embeddings> getEmbeddingsWithResponse(String deploymentOrModelName, EmbeddingsOptions embeddingsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Return the embeddings for a given prompt.Request Body Schema
{ user: String (Optional) model: String (Optional) input (Required): [ String (Required) ] }Response Body Schema
{ data (Required): [ (Required){ embedding (Required): [ double (Required) ] index: int (Required) } ] usage (Required): { prompt_tokens: int (Required) total_tokens: int (Required) } }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.embeddingsOptions- The configuration information for an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- representation of the response data from an embeddings request. Embeddings measure the relatedness of
text strings and are commonly used for search, clustering, recommendations, and other similar scenarios 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.
-
getCompletionsWithResponse
public com.azure.core.http.rest.Response<Completions> getCompletionsWithResponse(String deploymentOrModelName, CompletionsOptions completionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets completions for the provided input prompts. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.Request Body Schema
{ prompt (Required): [ String (Required) ] max_tokens: Integer (Optional) temperature: Double (Optional) top_p: Double (Optional) logit_bias (Optional): { String: int (Optional) } user: String (Optional) n: Integer (Optional) logprobs: Integer (Optional) echo: Boolean (Optional) stop (Optional): [ String (Optional) ] presence_penalty: Double (Optional) frequency_penalty: Double (Optional) best_of: Integer (Optional) stream: Boolean (Optional) model: String (Optional) }Response Body Schema
{ id: String (Required) created: int (Required) choices (Required): [ (Required){ text: String (Required) index: int (Required) logprobs (Required): { tokens (Required): [ String (Required) ] token_logprobs (Required): [ double (Required) ] top_logprobs (Required): [ (Required){ String: double (Required) } ] text_offset (Required): [ int (Required) ] } finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) } ] usage (Required): { completion_tokens: int (Required) prompt_tokens: int (Required) total_tokens: int (Required) } }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.completionsOptions- The configuration information for a completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- completions for the provided input prompts. 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.
-
getChatCompletionsWithResponse
public com.azure.core.http.rest.Response<ChatCompletions> getChatCompletionsWithResponse(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions, 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.Request Body Schema
{ messages (Required): [ (Required){ role: String(system/assistant/user) (Required) content: String (Optional) } ] max_tokens: Integer (Optional) temperature: Double (Optional) top_p: Double (Optional) logit_bias (Optional): { String: int (Optional) } user: String (Optional) n: Integer (Optional) stop (Optional): [ String (Optional) ] presence_penalty: Double (Optional) frequency_penalty: Double (Optional) stream: Boolean (Optional) model: String (Optional) }Response Body Schema
{ id: String (Required) created: int (Required) choices (Required): [ (Required){ message (Optional): { role: String(system/assistant/user) (Required) content: String (Optional) } index: int (Required) finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) delta (Optional): { role: String(system/assistant/user) (Optional) content: String (Optional) } } ] usage (Required): { completion_tokens: int (Required) prompt_tokens: int (Required) total_tokens: int (Required) } }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.chatCompletionsOptions- 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.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.
-
getEmbeddings
Return the embeddings for a given prompt.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.embeddingsOptions- The configuration information for an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.- Returns:
- representation of the response data from an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.
- 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.
-
getCompletions
public Completions getCompletions(String deploymentOrModelName, CompletionsOptions completionsOptions) Gets completions for the provided input prompts. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.completionsOptions- The configuration information for a completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Returns:
- completions for the provided input prompts. 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.
-
getCompletions
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:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.prompt- The prompt to generate completion text from.- Returns:
- completions for the provided input prompts. 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.
-
getCompletionsStream
public com.azure.core.util.IterableStream<Completions> getCompletionsStream(String deploymentOrModelName, CompletionsOptions completionsOptions) Gets completions as a stream for the provided input prompts. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.completionsOptions- The configuration information for a completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.- Returns:
- an
IterableStreamof completions for the provided input prompts. 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.
-
getChatCompletions
public ChatCompletions getChatCompletions(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions) 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.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.chatCompletionsOptions- 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 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.
-
getChatCompletionsStream
public com.azure.core.util.IterableStream<ChatCompletions> getChatCompletionsStream(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions) 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.Code Samples
openAIClient.getChatCompletionsStream(deploymentOrModelId, new ChatCompletionsOptions(chatMessages)) .forEach(chatCompletions -> { if (CoreUtils.isNullOrEmpty(chatCompletions.getChoices())) { return; } ChatResponseMessage delta = chatCompletions.getChoices().get(0).getDelta(); if (delta.getRole() != null) { System.out.println("Role = " + delta.getRole()); } if (delta.getContent() != null) { String content = delta.getContent(); System.out.print(content); } });- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.chatCompletionsOptions- 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.
-
getChatCompletionsStreamWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.IterableStream<ChatCompletions>> getChatCompletionsStreamWithResponse(String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions, com.azure.core.http.rest.RequestOptions requestOptions) 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.Code Samples
openAIClient .getChatCompletionsStreamWithResponse(deploymentOrModelId, new ChatCompletionsOptions(chatMessages), new RequestOptions().setHeader("my-header", "my-header-value")) .getValue() .forEach(chatCompletions -> { if (CoreUtils.isNullOrEmpty(chatCompletions.getChoices())) { return; } ChatResponseMessage delta = chatCompletions.getChoices().get(0).getDelta(); if (delta.getRole() != null) { System.out.println("Role = " + delta.getRole()); } if (delta.getContent() != null) { String content = delta.getContent(); System.out.print(content); } });- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.chatCompletionsOptions- 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.requestOptions- The options to configure the HTTP request before HTTP client sends it.- 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.
-
getAudioTranscription
public AudioTranscription getAudioTranscription(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions) Gets transcribed text and associated metadata from provided spoken audio file data. Audio will be transcribed in the written language corresponding to the language it was spoken in.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranscriptionOptions.audioTranscriptionOptions- The configuration information for an audio transcription request.- Returns:
AudioTranscriptiontranscribed text and associated metadata from provided spoken audio 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.
-
getAudioTranscriptionWithResponse
public com.azure.core.http.rest.Response<AudioTranscription> getAudioTranscriptionWithResponse(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets transcribed text and associated metadata from provided spoken audio file data. Audio will be transcribed in the written language corresponding to the language it was spoken in.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranscriptionOptions.audioTranscriptionOptions- The configuration information for an audio transcription request.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
AudioTranscriptiontranscribed text and associated metadata from provided spoken audio data along withResponse.- 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.
-
getAudioTranscriptionText
public String getAudioTranscriptionText(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions) Gets transcribed text and associated metadata from provided spoken audio file data. Audio will be transcribed in the written language corresponding to the language it was spoken in.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranscriptionOptions.audioTranscriptionOptions- The configuration information for an audio transcription request.- Returns:
- transcribed text and associated metadata from provided spoken audio 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.
-
getAudioTranscriptionTextWithResponse
public com.azure.core.http.rest.Response<String> getAudioTranscriptionTextWithResponse(String deploymentOrModelName, String fileName, AudioTranscriptionOptions audioTranscriptionOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets transcribed text and associated metadata from provided spoken audio file data. Audio will be transcribed in the written language corresponding to the language it was spoken in.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranscriptionOptions.audioTranscriptionOptions- The configuration information for an audio transcription request.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- transcribed text and associated metadata from provided spoken audio 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.
-
getAudioTranslation
public AudioTranslation getAudioTranslation(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranslationOptions.audioTranslationOptions- The configuration information for an audio translation request.- Returns:
AudioTranscriptionenglish language transcribed text and associated metadata from provided spoken audio file 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.
-
getAudioTranslationWithResponse
public com.azure.core.http.rest.Response<AudioTranslation> getAudioTranslationWithResponse(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranslationOptions.audioTranslationOptions- The configuration information for an audio translation request.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
AudioTranslationenglish language transcribed text and associated metadata from provided spoken audio file data along withResponse.- 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.
-
getAudioTranslationText
public String getAudioTranslationText(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranslationOptions.audioTranslationOptions- The configuration information for an audio translation request.- Returns:
- english language transcribed text and associated metadata from provided spoken audio file 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.
-
getAudioTranslationTextWithResponse
public com.azure.core.http.rest.Response<String> getAudioTranslationTextWithResponse(String deploymentOrModelName, String fileName, AudioTranslationOptions audioTranslationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Gets English language transcribed text and associated metadata from provided spoken audio file data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.fileName- The file name that is represented in thefilefield ofAudioTranslationOptions.audioTranslationOptions- The configuration information for an audio translation request.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- english language transcribed text and associated metadata from provided spoken audio file data along with
Response. - 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.
-
getAudioTranscriptionAsPlainText
public String getAudioTranscriptionAsPlainText(String deploymentOrModelName, AudioTranscriptionOptions audioTranscriptionOptions) Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the written language corresponding to the language it was spoken in.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.audioTranscriptionOptions- The configuration information for an audio transcription request.- Returns:
- transcribed text and associated metadata from provided spoken audio 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.
-
getAudioTranslationAsPlainText
public String getAudioTranslationAsPlainText(String deploymentOrModelName, AudioTranslationOptions audioTranslationOptions) Gets English language transcribed text and associated metadata from provided spoken audio data.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.audioTranslationOptions- The configuration information for an audio translation request.- Returns:
- english language transcribed text and associated metadata from provided spoken audio 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.
-
getImageGenerationsWithResponse
public com.azure.core.http.rest.Response<ImageGenerations> getImageGenerationsWithResponse(String deploymentOrModelName, ImageGenerationOptions imageGenerationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Creates an image given a prompt.Request Body Schema
{ model: String (Optional) prompt: String (Required) n: Integer (Optional) size: String(256x256/512x512/1024x1024/1792x1024/1024x1792) (Optional) response_format: String(url/b64_json) (Optional) quality: String(standard/hd) (Optional) style: String(natural/vivid) (Optional) user: String (Optional) }Response Body Schema
{ created: long (Required) data (Required): [ (Required){ url: String (Optional) b64_json: String (Optional) revised_prompt: String (Optional) } ] }- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.imageGenerationOptions- Represents the request data used to generate images.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- the result of a successful image generation operation 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.
-
getImageGenerations
public ImageGenerations getImageGenerations(String deploymentOrModelName, ImageGenerationOptions imageGenerationOptions) Creates an image given a prompt.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.imageGenerationOptions- Represents the request data used to generate images.- Returns:
- the result of a successful image generation operation.
- 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.
-
generateSpeechFromTextWithResponse
public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> generateSpeechFromTextWithResponse(String deploymentOrModelName, com.azure.core.util.BinaryData speechGenerationOptions, com.azure.core.http.rest.RequestOptions requestOptions) Generates text-to-speech audio from the input text.Request Body Schema
{ input: String (Required) voice: String(alloy/echo/fable/onyx/nova/shimmer) (Required) response_format: String(mp3/opus/aac/flac) (Optional) speed: Double (Optional) }Response Body Schema
BinaryData- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.speechGenerationOptions- A representation of the request options that control the behavior of a text-to-speech operation.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- the response body 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.
-
generateSpeechFromText
public com.azure.core.util.BinaryData generateSpeechFromText(String deploymentOrModelName, SpeechGenerationOptions speechGenerationOptions) Generates text-to-speech audio from the input text.- Parameters:
deploymentOrModelName- Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.speechGenerationOptions- A representation of the request options that control the behavior of a text-to-speech operation.- Returns:
- the response.
- 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.
-
listFilesWithResponse
public com.azure.core.http.rest.Response<List<OpenAIFile>> listFilesWithResponse(com.azure.core.http.rest.RequestOptions requestOptions) Gets a list of previously uploaded files.Query Parameters
You can add these to a request withQuery Parameters Name Type Required Description purpose String No A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune", "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision". RequestOptions.addQueryParam(java.lang.String, java.lang.String)Response Body Schema
{ object: String (Required) data (Required): [ (Required){ object: String (Required) id: String (Required) bytes: int (Required) filename: String (Required) created_at: long (Required) purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required) status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional) status_details: String (Optional) } ] }- Parameters:
requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- a list of previously uploaded files 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.
-
deleteFileWithResponse
public com.azure.core.http.rest.Response<FileDeletionStatus> deleteFileWithResponse(String fileId, com.azure.core.http.rest.RequestOptions requestOptions) Delete a previously uploaded file.Response Body Schema
{ id: String (Required) deleted: boolean (Required) object: String (Required) }- Parameters:
fileId- The ID of the file to delete.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- a status response from a file deletion operation 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.
-
getFileWithResponse
public com.azure.core.http.rest.Response<OpenAIFile> getFileWithResponse(String fileId, com.azure.core.http.rest.RequestOptions requestOptions) Returns information about a specific file. Does not retrieve file content.Response Body Schema
{ object: String (Required) id: String (Required) bytes: int (Required) filename: String (Required) created_at: long (Required) purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required) status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional) status_details: String (Optional) }- Parameters:
fileId- The ID of the file to retrieve.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- represents an assistant that can call the model and use tools 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.
-
getFileContentWithResponse
public com.azure.core.http.rest.Response<byte[]> getFileContentWithResponse(String fileId, com.azure.core.http.rest.RequestOptions requestOptions) Returns information about a specific file. Does not retrieve file content.Response Body Schema
byte[]- Parameters:
fileId- The ID of the file to retrieve.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- represent a byte array 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.
-
listBatchesWithResponse
public com.azure.core.http.rest.Response<PageableList<Batch>> listBatchesWithResponse(com.azure.core.http.rest.RequestOptions requestOptions) Gets a list of all batches owned by the Azure OpenAI resource.Query Parameters
You can add these to a request withQuery Parameters Name Type Required Description after String No Identifier for the last event from the previous pagination request. limit Integer No Number of batches to retrieve. Defaults to 20. RequestOptions.addQueryParam(java.lang.String, java.lang.String)Response Body Schema
{ object: String (Required) data (Optional): [ (Optional){ id: String (Required) object: String (Required) endpoint: String (Optional) errors (Optional): { object: String (Required) data (Optional): [ (Optional){ code: String (Optional) message: String (Optional) param: String (Optional) line: Integer (Optional) } ] } input_file_id: String (Required) completion_window: String (Optional) status: String(validating/failed/in_progress/finalizing/completed/expired/cancelling/cancelled) (Optional) output_file_id: String (Optional) error_file_id: String (Optional) created_at: Long (Optional) in_progress_at: Long (Optional) expires_at: Long (Optional) finalizing_at: Long (Optional) completed_at: Long (Optional) failed_at: Long (Optional) expired_at: Long (Optional) cancelling_at: Long (Optional) cancelled_at: Long (Optional) request_counts (Optional): { total: Integer (Optional) completed: Integer (Optional) failed: Integer (Optional) } metadata (Optional): { String: String (Required) } } ] first_id: String (Optional) last_id: String (Optional) has_more: Boolean (Optional) }- Parameters:
requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- a list of all batches owned by the Azure OpenAI resource 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.
-
createBatchWithResponse
public com.azure.core.http.rest.Response<Batch> createBatchWithResponse(com.azure.core.util.BinaryData createBatchRequest, com.azure.core.http.rest.RequestOptions requestOptions) Creates and executes a batch from an uploaded file of requests. Response includes details of the enqueued job including job status. The ID of the result file is added to the response once complete.Request Body Schema
{ endpoint: String (Required) input_file_id: String (Required) completion_window: String (Required) metadata (Optional): { String: String (Required) } }Response Body Schema
{ id: String (Required) object: String (Required) endpoint: String (Optional) errors (Optional): { object: String (Required) data (Optional): [ (Optional){ code: String (Optional) message: String (Optional) param: String (Optional) line: Integer (Optional) } ] } input_file_id: String (Required) completion_window: String (Optional) status: String(validating/failed/in_progress/finalizing/completed/expired/cancelling/cancelled) (Optional) output_file_id: String (Optional) error_file_id: String (Optional) created_at: Long (Optional) in_progress_at: Long (Optional) expires_at: Long (Optional) finalizing_at: Long (Optional) completed_at: Long (Optional) failed_at: Long (Optional) expired_at: Long (Optional) cancelling_at: Long (Optional) cancelled_at: Long (Optional) request_counts (Optional): { total: Integer (Optional) completed: Integer (Optional) failed: Integer (Optional) } metadata (Optional): { String: String (Required) } }- Parameters:
createBatchRequest- The specification of the batch to create and execute.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- the Batch object 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.
-
getBatchWithResponse
public com.azure.core.http.rest.Response<Batch> getBatchWithResponse(String batchId, com.azure.core.http.rest.RequestOptions requestOptions) Gets details for a single batch specified by the given batchID.Response Body Schema
{ id: String (Required) object: String (Required) endpoint: String (Optional) errors (Optional): { object: String (Required) data (Optional): [ (Optional){ code: String (Optional) message: String (Optional) param: String (Optional) line: Integer (Optional) } ] } input_file_id: String (Required) completion_window: String (Optional) status: String(validating/failed/in_progress/finalizing/completed/expired/cancelling/cancelled) (Optional) output_file_id: String (Optional) error_file_id: String (Optional) created_at: Long (Optional) in_progress_at: Long (Optional) expires_at: Long (Optional) finalizing_at: Long (Optional) completed_at: Long (Optional) failed_at: Long (Optional) expired_at: Long (Optional) cancelling_at: Long (Optional) cancelled_at: Long (Optional) request_counts (Optional): { total: Integer (Optional) completed: Integer (Optional) failed: Integer (Optional) } metadata (Optional): { String: String (Required) } }- Parameters:
batchId- The identifier of the batch.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- details for a single batch specified by the given batchID 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.
-
cancelBatchWithResponse
public com.azure.core.http.rest.Response<Batch> cancelBatchWithResponse(String batchId, com.azure.core.http.rest.RequestOptions requestOptions) Gets details for a single batch specified by the given batchID.Response Body Schema
{ id: String (Required) object: String (Required) endpoint: String (Optional) errors (Optional): { object: String (Required) data (Optional): [ (Optional){ code: String (Optional) message: String (Optional) param: String (Optional) line: Integer (Optional) } ] } input_file_id: String (Required) completion_window: String (Optional) status: String(validating/failed/in_progress/finalizing/completed/expired/cancelling/cancelled) (Optional) output_file_id: String (Optional) error_file_id: String (Optional) created_at: Long (Optional) in_progress_at: Long (Optional) expires_at: Long (Optional) finalizing_at: Long (Optional) completed_at: Long (Optional) failed_at: Long (Optional) expired_at: Long (Optional) cancelling_at: Long (Optional) cancelled_at: Long (Optional) request_counts (Optional): { total: Integer (Optional) completed: Integer (Optional) failed: Integer (Optional) } metadata (Optional): { String: String (Required) } }- Parameters:
batchId- The identifier of the batch.requestOptions- The options to configure the HTTP request before HTTP client sends it.- Returns:
- details for a single batch specified by the given batchID 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.
-
listFiles
Gets a list of previously uploaded files.- Parameters:
purpose- A value that, when provided, limits list results to files matching the corresponding purpose.- Returns:
- a list of previously uploaded files.
- 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.
-
listFiles
Gets a list of previously uploaded files.- Returns:
- a list of previously uploaded files.
- 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.
-
uploadFile
Uploads a file for use by other operations.- Parameters:
file- The file data (not filename) to upload.purpose- The intended purpose of the file.- Returns:
- represents an assistant that can call the model and use tools.
- 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.
-
deleteFile
Delete a previously uploaded file.- Parameters:
fileId- The ID of the file to delete.- Returns:
- a status response from a file deletion operation.
- 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.
-
getFile
Returns information about a specific file. Does not retrieve file content.- Parameters:
fileId- The ID of the file to retrieve.- Returns:
- represents an assistant that can call the model and use tools.
- 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.
-
getFileContent
Returns information about a specific file. Does not retrieve file content.- Parameters:
fileId- The ID of the file to retrieve.- Returns:
- represent a byte array.
- 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.
-
listBatches
Gets a list of all batches owned by the Azure OpenAI resource.- Parameters:
after- Identifier for the last event from the previous pagination request.limit- The number of batches to retrieve. The default is 20.- Returns:
- a list of all batches owned by the Azure OpenAI resource.
- 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.
-
listBatches
Gets a list of all batches owned by the Azure OpenAI resource.- Returns:
- a list of all batches owned by the Azure OpenAI resource.
- 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.
-
getBatch
Gets details for a single batch specified by the given batchID.- Parameters:
batchId- The identifier of the batch.- Returns:
- details for a single batch specified by the given batchID.
- 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.
-
cancelBatch
Gets details for a single batch specified by the given batchID.- Parameters:
batchId- The identifier of the batch.- Returns:
- details for a single batch specified by the given batchID.
- 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.
-
createBatch
Creates and executes a batch from an uploaded file of requests. Response includes details of the enqueued job including job status. The ID of the result file is added to the response once complete.- Parameters:
createBatchRequest- The specification of the batch to create and execute.- Returns:
- the Batch object.
- 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.
-