File tree Expand file tree Collapse file tree 5 files changed +178
-1
lines changed
Expand file tree Collapse file tree 5 files changed +178
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : Embeddings
3+ ---
4+
5+ !!! Note
6+
7+ Please build the client before calling, the build code is as follows:
8+
9+ ```java
10+ OpenAiClient client = OpenAiClient.builder()
11+ .apiHost("https://api.openai.com")
12+ .apiKey(System.getProperty("openai.token"))
13+ .build();
14+ ```
15+
16+ `System.getProperty("openai.token")` is the key to access the API authorization.
17+
18+ ### Create embeddings
19+
20+ ---
21+
22+ Creates an embedding vector representing the input text.
23+
24+ ``` java
25+ EmbeddingEntity configure= EmbeddingEntity . builder()
26+ .model(" text-similarity-ada-001" )
27+ .input(" Hello OpenAi Java SDK" )
28+ .build();
29+ client. createEmbeddings(configure);
30+ ```
31+
32+ Return
33+
34+ ``` json
35+ {
36+ "object" : " list" ,
37+ "data" : [
38+ {
39+ "object" : " embedding" ,
40+ "embedding" : [
41+ 0.0023064255 ,
42+ -0.009327292 ,
43+ .... (1536 floats total for ada-002)
44+ -0.0028842222 ,
45+ ],
46+ "index" : 0
47+ }
48+ ],
49+ "model" : " text-embedding-ada-002" ,
50+ "usage" : {
51+ "prompt_tokens" : 8 ,
52+ "total_tokens" : 8
53+ }
54+ }
55+ ```
Original file line number Diff line number Diff line change 1+ ---
2+ title : Images
3+ ---
4+
5+ !!! Note
6+
7+ Please build the client before calling, the build code is as follows:
8+
9+ ```java
10+ OpenAiClient client = OpenAiClient.builder()
11+ .apiHost("https://api.openai.com")
12+ .apiKey(System.getProperty("openai.token"))
13+ .build();
14+ ```
15+
16+ `System.getProperty("openai.token")` is the key to access the API authorization.
17+
18+ ### Create images
19+
20+ ---
21+
22+ Creates an image given a prompt.
23+
24+ ``` java
25+ ImageEntity configure= ImageEntity . builder()
26+ .prompt(" Create a bus" )
27+ .build();
28+ client. createImages(configure)
29+ ```
30+
31+ Returns
32+
33+ ``` json
34+ {
35+ "created" : 1589478378 ,
36+ "data" : [
37+ {
38+ "url" : " https://..."
39+ },
40+ {
41+ "url" : " https://..."
42+ }
43+ ]
44+ }
45+ ```
46+
47+ ### Create image edit
48+
49+ ---
50+
51+ Creates an edited or extended image given an original image and a prompt.
52+
53+ ``` java
54+ String file= this . getClass(). getResource(" /logo.png" ). getFile();
55+ ImageEntity configure= ImageEntity . builder()
56+ .prompt(" Add hello to image" )
57+ .image(new File (file))
58+ .isEdit(Boolean . TRUE )
59+ .build();
60+ client. editImages(configure);
61+ ```
62+
63+ Returns
64+
65+ ``` json
66+ {
67+ "created" : 1589478378 ,
68+ "data" : [
69+ {
70+ "url" : " https://..."
71+ },
72+ {
73+ "url" : " https://..."
74+ }
75+ ]
76+ }
77+ ```
78+
79+ ### Create image variation
80+
81+ ---
82+
83+ Creates a variation of a given image.
84+
85+ ``` java
86+ String file= this . getClass(). getResource(" /logo.png" ). getFile();
87+ ImageEntity configure= ImageEntity . builder()
88+ .image(new File (file))
89+ .isVariation(Boolean . TRUE )
90+ .build();
91+ client. variationsImages(configure);
92+ ```
93+
94+ Return
95+
96+ ``` json
97+ {
98+ "created" : 1589478378 ,
99+ "data" : [
100+ {
101+ "url" : " https://..."
102+ },
103+ {
104+ "url" : " https://..."
105+ }
106+ ]
107+ }
108+ ```
109+
Original file line number Diff line number Diff line change 55 - navigation
66---
77
8+ ### 1.4.0
9+
10+ ---
11+
12+ - Support images api
13+ - Create image
14+ - Create image edit
15+ - Create image variation
16+ - Support embeddings api
17+ - Create embeddings
18+
819### 1.3.0
920
1021---
Original file line number Diff line number Diff line change 4848 - reference/models.md
4949 - reference/completions.md
5050 - reference/completions_chat.md
51+ - reference/images.md
52+ - reference/embeddings.md
5153 - Provider :
5254 - reference/provider/azure.md
5355 - released.md
Original file line number Diff line number Diff line change 55
66 <groupId >org.devlive.sdk</groupId >
77 <artifactId >openai-java-sdk</artifactId >
8- <version >1.4.0-SNAPSHOT </version >
8+ <version >1.4.0</version >
99
1010 <name >openai-java-sdk</name >
1111 <description >
You can’t perform that action at this time.
0 commit comments