You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-6
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,40 @@ A Java library to use the OpenAI Api in the simplest possible way.
8
8
9
9
10
10
## 💡 Description
11
-
Simple-OpenAI is a Java http client library for sending requests to and receiving responses from the [OpenAI Api](https://platform.openai.com/docs/api-reference). It exposes a consistent interface across all the services, yet as simple as you can find in other languages like Python or NodeJs. It's a _community-maintained_ library.
11
+
Simple-OpenAI is a Java http client library for sending requests to and receiving responses from the [OpenAI API](https://platform.openai.com/docs/api-reference). It exposes a consistent interface across all the services, yet as simple as you can find in other languages like Python or NodeJs. It's a _community-maintained_ library.
12
12
13
-
Simple-OpenAI uses the [CleverClient](https://github.com/sashirestela/cleverclient) library for http communication, [Jackson](https://github.com/FasterXML/jackson) for Json parsing, and [Lombok](https://projectlombok.org/) to minimize boilerplate code.
13
+
Simple-OpenAI uses the [CleverClient](https://github.com/sashirestela/cleverclient) library for http communication, [Jackson](https://github.com/FasterXML/jackson) for Json parsing, and [Lombok](https://projectlombok.org/) to minimize boilerplate code, among others libraries.
14
+
15
+
16
+
## ✴ Support for Other OpenAI Providers
17
+
Simple-OpenAI can be used with other providers that are compatible with the OpenAI API. At this moment, there is support for the following providers:
18
+
19
+
### Azure OpenAI
20
+
[Azure OpenIA](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) is supported by Simple-OpenAI. We can use the class `SimpleOpenAIAzure`, which extends the class `BaseSimpleOpenAI`, to start using this provider.
21
+
```java
22
+
var openai =SimpleOpenAIAzure.builder()
23
+
.apiKey(System.getenv("AZURE_OPENAI_API_KEY"))
24
+
.baseUrl(System.getenv("AZURE_OPENAI_BASE_URL")) // Including resourceName and deploymentId
//.httpClient(customHttpClient) Optionally you could pass a custom HttpClient
27
+
.build();
28
+
```
29
+
Currently we are supporting the `openai.chatCompletionService()` service only.
30
+
31
+
### Anyscale
32
+
[Anyscale](https://www.anyscale.com/endpoints) is suported by Simple-OpenAI. We can use the class `SimpleOpenAIAnyscale`, which extends the class `BaseSimpleOpenAI`, to start using this provider.
33
+
```java
34
+
var openai =SimpleOpenAIAnyscale.builder()
35
+
.apiKey(System.getenv("AZURE_OPENAI_API_KEY"))
36
+
//.baseUrl(customUrl) Optionally you could pass a custom baseUrl
37
+
//.httpClient(customHttpClient) Optionally you could pass a custom HttpClient
38
+
.build();
39
+
```
40
+
Currently we are supporting the `openai.chatCompletionService()` service only. It was tested with the model Mistral.
14
41
15
42
16
43
## ✅ Supported Services
17
-
Full support for all of the OpenAI services, including the latest changes announced at the [DevDay](https://openai.com/blog/new-models-and-developer-products-announced-at-devday) on Nov 6th, 2023:
44
+
Full support for all of the OpenAI services:
18
45
19
46
* Text to speech (as part of Audio)
20
47
* Speech to text (as part of Audio)
@@ -69,7 +96,7 @@ var openai = SimpleOpenAI.builder()
Optionally, as well, you could provide a custom Java HttpClient object if you want to have more options for the http connection, such as executor, proxy, timeout, cookies, etc. ([See here](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html) for more details). In the following example we are providing a custom HttpClient:
99
+
Optionally, as well, you could provide a custom Java HttpClient object if you want to have more options for the http connection, such as executors, proxy, timeout, cookies, etc. ([See here](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html) for more details). In the following example we are providing a custom HttpClient:
73
100
```java
74
101
var httpClient =HttpClient.newBuilder()
75
102
.version(Version.HTTP_1_1)
@@ -86,10 +113,10 @@ var openai = SimpleOpenAI.builder()
86
113
```
87
114
88
115
### Calling the SimpleOpenAI Services
89
-
After you have created a SimpleOpenAI object, you are ready to call its services in order to communicate to OpenAI Api. Let's see some examples.
116
+
After you have created a SimpleOpenAI object, you are ready to call its services in order to communicate to OpenAI API. Let's see some examples.
90
117
91
118
#### Audio Service
92
-
Example to call th Audio service to transform text to audio. We are requesting to receive the audio in binary format (InputStream):
119
+
Example to call the Audio service to transform text to audio. We are requesting to receive the audio in binary format (InputStream):
0 commit comments