Interface OpenAiService


public interface OpenAiService
Service interface for interacting with the OpenAI API.
Author:
HamaWhite
  • Method Details

    • listModels

      @GET("models") io.reactivex.Single<ModelResp> listModels()
      Lists the currently available models, and provides basic information about each one such as the owner and availability.
      Returns:
      a Single emitting the response containing the list of available models
    • retrieveModel

      @GET("models/{model}") io.reactivex.Single<Model> retrieveModel(@Path("model") String model)
      Retrieves a model instance, providing basic information about the model such as the owner and permissions.
      Parameters:
      model - the ID of the model to use for this request
      Returns:
      a Single emitting the response containing the retrieved model
    • createCompletion

      @POST("completions") io.reactivex.Single<CompletionResp> createCompletion(@Body Completion completion)
      Creates a completion for the provided prompt and parameters.
      Parameters:
      completion - the completion request object containing the prompt and parameters
      Returns:
      a Single emitting the response containing the completion result
    • createCompletion

      @POST("{deploymentId}/completions") io.reactivex.Single<CompletionResp> createCompletion(@Path("deploymentId") String deploymentId, @Query("api-version") String apiVersion, @Body Completion completion)
      Creates a completion for the provided prompt and parameters, using azure openai.
      Parameters:
      deploymentId - The deploymentId for azure openai url.
      apiVersion - The apiVersion for azure openai url parameter 'api-version'.
      completion - the completion request object containing the prompt and parameters
      Returns:
      a Single emitting the response containing the completion result
    • streamCompletion

      @Streaming @POST("completions") retrofit2.Call<okhttp3.ResponseBody> streamCompletion(@Body Completion completion)
      Creates a stream completion for the provided prompt and parameters.
      Parameters:
      completion - the completion request object containing the prompt and parameters
      Returns:
      a Single emitting the response containing the completion result
    • createChatCompletion

      @POST("chat/completions") io.reactivex.Single<ChatCompletionResp> createChatCompletion(@Body ChatCompletion chatCompletion)
      Creates a response for the given chat conversation.
      Parameters:
      chatCompletion - the chat completion request object containing the chat conversation
      Returns:
      a Single emitting the response containing the chat completion result
    • createChatCompletion

      @POST("{deploymentId}/chat/completions") io.reactivex.Single<ChatCompletionResp> createChatCompletion(@Path("deploymentId") String deploymentId, @Query("api-version") String apiVersion, @Body ChatCompletion chatCompletion)
      Creates a model response for the given chat conversation, using azure openai.
      Parameters:
      deploymentId - The deploymentId for azure openai url.
      apiVersion - The apiVersion for azure openai url parameter 'api-version'.
      chatCompletion - the chat completion request object containing the chat conversation
      Returns:
      a Single emitting the response containing the chat completion result
    • streamChatCompletion

      @Streaming @POST("chat/completions") retrofit2.Call<okhttp3.ResponseBody> streamChatCompletion(@Body ChatCompletion chatCompletion)
      Creates a stream response for the given chat conversation.
      Parameters:
      chatCompletion - the chat completion request object
      Returns:
      a Call representing the streaming response
    • createEmbedding

      @POST("embeddings") io.reactivex.Single<EmbeddingResp> createEmbedding(@Body Embedding embedding)
      Creates an embedding vector representing the input text.
      Parameters:
      embedding - The Embedding object containing the input text.
      Returns:
      A Single object that emits an EmbeddingResp, representing the response containing the embedding vector.
    • createEmbedding

      @POST("{deploymentId}/embeddings") io.reactivex.Single<EmbeddingResp> createEmbedding(@Path("deploymentId") String deploymentId, @Query("api-version") String apiVersion, @Body Embedding embedding)
      Creates an embedding vector representing the input text, using azure openai.
      Parameters:
      deploymentId - The deploymentId for azure openai url.
      apiVersion - The apiVersion for azure openai url parameter 'api-version'.
      embedding - The Embedding object containing the input text.
      Returns:
      A Single object that emits an EmbeddingResp, representing the response containing the embedding vector.
    • createImage

      @POST("images/generations") io.reactivex.Single<ImageResp> createImage(@Body CreateImageReq request)
      Creates an image given a prompt.
      Parameters:
      request - the create image request
      Returns:
      A Single emitting the response containing the generated image.