Open AI
The main interface for the OpenAI API. This interface contains methods for all the API endpoints. To instantiate an instance of this interface, use builder.
All the methods in this class are blocking (except the stream methods, streamCompletion and streamChatCompletion, which return an iterator which blocks the thread).
The methods in this class all throw io exceptions if the request fails. The error message will contain the JSON response from the API (if present). Common errors include:
Not having a valid API key
Passing a bad parameter to a request
Inheritors
Functions
Returns the handler for the assistants endpoint. This method is purely syntactic sugar for Java users.
Calls the chat completions API endpoint. This method is blocking.
Calls the completions API endpoint. This method is blocking.
Calls the embeddings API endpoint to generate the vector representation of text. The returned vector can be used in Machine Learning models. This method is blocking.
Returns the handler for the files endpoint. This method is purely syntactic sugar for Java users.
Calls the chat completions API endpoint and streams each token 1 at a time for a faster response.
Extension function to stream a chat completion using kotlin coroutines.
Calls the completions API endpoint and streams each token 1 at a time for a faster response time.
Extension function to stream a completion using kotlin coroutines.
Returns the handler for the threads endpoint. This method is purely syntactic sugar for Java users.
Properties
Returns the handler for the assistants endpoint. This handler can be used to create, retrieve, and delete assistants.
Returns the handler for the files endpoint. This handler can be used to create, retrieve, and delete files.
Returns the handler for the threads endpoint. This handler can be used to create, retrieve, and delete threads.