Skip to content

Commit dce52af

Browse files
docs: add client documentation (#166)
1 parent cf8244d commit dce52af

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ import com.openai.services.blocking.ModelService
1414
import com.openai.services.blocking.ModerationService
1515
import com.openai.services.blocking.UploadService
1616

17+
/**
18+
* A client for interacting with the OpenAI REST API synchronously. You can also switch to
19+
* asynchronous execution via the [async] method.
20+
*
21+
* This client performs best when you create a single instance and reuse it for all interactions
22+
* with the REST API. This is because each client holds its own connection pool and thread pools.
23+
* Reusing connections and threads reduces latency and saves memory. The client also handles rate
24+
* limiting per client. This means that creating and using multiple instances at the same time will
25+
* not respect rate limits.
26+
*
27+
* The threads and connections that are held will be released automatically if they remain idle. But
28+
* if you are writing an application that needs to aggressively release unused resources, then you
29+
* may call [close].
30+
*/
1731
interface OpenAIClient {
1832

1933
fun async(): OpenAIClientAsync

openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsync.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ import com.openai.services.async.ModelServiceAsync
1414
import com.openai.services.async.ModerationServiceAsync
1515
import com.openai.services.async.UploadServiceAsync
1616

17+
/**
18+
* A client for interacting with the OpenAI REST API asynchronously. You can also switch to
19+
* synchronous execution via the [sync] method.
20+
*
21+
* This client performs best when you create a single instance and reuse it for all interactions
22+
* with the REST API. This is because each client holds its own connection pool and thread pools.
23+
* Reusing connections and threads reduces latency and saves memory. The client also handles rate
24+
* limiting per client. This means that creating and using multiple instances at the same time will
25+
* not respect rate limits.
26+
*
27+
* The threads and connections that are held will be released automatically if they remain idle. But
28+
* if you are writing an application that needs to aggressively release unused resources, then you
29+
* may call [close].
30+
*/
1731
interface OpenAIClientAsync {
1832

1933
fun sync(): OpenAIClient

0 commit comments

Comments
 (0)