OpenAIAsyncClient Class
- java.
lang. Object - com.
azure. ai. openai. OpenAIAsyncClient
- com.
public final class OpenAIAsyncClient
Initializes a new instance of the asynchronous OpenAIClient type.
Method Summary
Methods inherited from java.lang.Object
Method Details
generateSpeechFromText
public Mono
Generates text-to-speech audio from the input text.
Parameters:
Returns:
generateSpeechFromTextWithResponse
public Mono<>
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:
Returns:
getAudioTranscription
public Mono
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:
Returns:
getAudioTranscriptionAsPlainText
public Mono
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:
Returns:
getAudioTranscriptionText
public Mono
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:
Returns:
getAudioTranscriptionTextWithResponse
public Mono<>
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:
Returns:
getAudioTranscriptionWithResponse
public Mono<>
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:
Returns:
getAudioTranslation
public Mono
Gets English language transcribed text and associated metadata from provided spoken audio file data.
Parameters:
Returns:
getAudioTranslationAsPlainText
public Mono
Gets English language transcribed text and associated metadata from provided spoken audio data.
Parameters:
Returns:
getAudioTranslationText
public Mono
Gets English language transcribed text and associated metadata from provided spoken audio file data.
Parameters:
Returns:
getAudioTranslationTextWithResponse
public Mono<>
Gets English language transcribed text and associated metadata from provided spoken audio file data.
Parameters:
Returns:
getAudioTranslationWithResponse
public Mono<>
Gets English language transcribed text and associated metadata from provided spoken audio file data.
Parameters:
Returns:
getChatCompletions
public Mono
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:
Returns:
getChatCompletionsStream
public Flux
Gets chat completions for the provided chat messages. Chat completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.
Parameters:
Returns:
getChatCompletionsStreamWithResponse
public Flux<>
Gets chat completions for the provided chat messages. Chat completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data.
Code Samples
openAIAsyncClient.getChatCompletionsStreamWithResponse(deploymentOrModelId, new ChatCompletionsOptions(chatMessages),
new RequestOptions().setHeader("my-header", "my-header-value"))
.subscribe(
response -> System.out.print(response.getValue().getId()),
error -> System.err.println("There was an error getting chat completions." + error),
() -> System.out.println("Completed called getChatCompletionsStreamWithResponse."));
Parameters:
Returns:
getChatCompletionsWithResponse
public Mono<>
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:
Returns:
getChatCompletionsWithResponse
public Mono<>
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:
Returns:
getCompletions
public Mono
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:
Returns:
getCompletions
public Mono
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:
Returns:
getCompletionsStream
public Flux
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.
Code Samples
openAIAsyncClient
.getChatCompletionsStream(deploymentOrModelId, new ChatCompletionsOptions(chatMessages))
.subscribe(
chatCompletions -> System.out.print(chatCompletions.getId()),
error -> System.err.println("There was an error getting chat completions." + error),
() -> System.out.println("Completed called getChatCompletionsStream."));
Parameters:
Returns:
getCompletionsWithResponse
public Mono<>
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:
Returns:
getCompletionsWithResponse
public Mono<>
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:
Returns:
getEmbeddings
public Mono
Return the embeddings for a given prompt.
Parameters:
Returns:
getEmbeddingsWithResponse
public Mono<>
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:
Returns:
getEmbeddingsWithResponse
public Mono<>
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:
Returns:
getImageGenerations
public Mono
Creates an image given a prompt.
Parameters:
Returns:
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for