forked from openai/openai-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmbeddingsAsyncExample.java
More file actions
24 lines (19 loc) · 948 Bytes
/
Copy pathEmbeddingsAsyncExample.java
File metadata and controls
24 lines (19 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.openai.example;
import com.openai.client.OpenAIClientAsync;
import com.openai.client.okhttp.OpenAIOkHttpClientAsync;
import com.openai.models.embeddings.EmbeddingCreateParams;
import com.openai.models.embeddings.EmbeddingModel;
public final class EmbeddingsAsyncExample {
private EmbeddingsAsyncExample() {}
public static void main(String[] args) {
// Configures using one of:
// - The `OPENAI_API_KEY` environment variable
// - The `OPENAI_BASE_URL` and `AZURE_OPENAI_KEY` environment variables
OpenAIClientAsync client = OpenAIOkHttpClientAsync.fromEnv();
EmbeddingCreateParams createParams = EmbeddingCreateParams.builder()
.input("The quick brown fox jumped over the lazy dog")
.model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)
.build();
client.embeddings().create(createParams).thenAccept(System.out::println).join();
}
}