Interface OpenAiApi


public interface OpenAiApi
Retrofit2 API interface
  • Method Details

    • listModels

      @GET("/v1/models") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<Model>> listModels()
      List models
      Returns:
      Lists the currently available models, and provides basic information about each one such as the owner and availability.
    • getModel

      @GET("/v1/models/{model_id}") io.reactivex.rxjava3.core.Single<Model> getModel(@Path("model_id") String modelId)
      Retrieve model
      Parameters:
      modelId - model ID
      Returns:
      Retrieves a model instance, providing basic information about the model such as the owner and permission.
    • createChatCompletion

      @POST("/v1/chat/completions") io.reactivex.rxjava3.core.Single<ChatCompletion> createChatCompletion(@Body CreateChatCompletionRequest request)
      Create chat completionBeta Creates a completion for the chat message
      Parameters:
      request - Create chat completion request
      Returns:
      Chat Completion information
    • createImage

      @POST("/v1/images/generations") io.reactivex.rxjava3.core.Single<ImageResponse> createImage(@Body CreateImageRequest request)
      Create image Beta Creates an image given a prompt.
      Parameters:
      request - create image request
      Returns:
      Image Information Wrapper
    • createImageEdit

      @POST("/v1/images/edits") io.reactivex.rxjava3.core.Single<ImageResponse> createImageEdit(@Body okhttp3.RequestBody request)
      Create image editBeta Creates an edited or extended image given an original image and a prompt.
      Parameters:
      request - request body
      Returns:
      Image Information Wrapper
    • createImageVariation

      @POST("/v1/images/variations") io.reactivex.rxjava3.core.Single<ImageResponse> createImageVariation(@Body okhttp3.RequestBody request)
      Create image variationBeta Creates a variation of a given image.
      Parameters:
      request - request body
      Returns:
      Image Information Wrapper
    • createEmbedding

      @POST("/v1/embeddings") io.reactivex.rxjava3.core.Single<CreateEmbeddingResponse> createEmbedding(@Body CreateEmbeddingRequest request)
      Create embeddings Creates an embedding vector representing the input text.
      Parameters:
      request - create embedding request
      Returns:
      Embeddings
    • createSpeech

      @POST("/v1/audio/speech") io.reactivex.rxjava3.core.Single<okhttp3.ResponseBody> createSpeech(@Body CreateSpeechRequest request)
      Generates audio from the input text.
      Parameters:
      request - create speech request
      Returns:
      audio file
    • createAudioTranscription

      @POST("/v1/audio/transcriptions") io.reactivex.rxjava3.core.Single<AudioResponse> createAudioTranscription(@Body okhttp3.RequestBody request)
      Create transcriptionBeta Transcribes audio into the input language.
      Parameters:
      request - body
      Returns:
      Text of audio
    • createAudioTranslation

      @POST("/v1/audio/translations") io.reactivex.rxjava3.core.Single<AudioResponse> createAudioTranslation(@Body okhttp3.RequestBody request)
      Create translationBeta Translates audio into English.
      Parameters:
      request - body
      Returns:
      Text of audio
    • createModeration

      @POST("/v1/moderations") io.reactivex.rxjava3.core.Single<CreateModerationResponse> createModeration(@Body CreateModerationRequest request)
      Create moderation Classifies if text violates OpenAI's Content Policy
      Parameters:
      request - create moderation request
      Returns:
      Moderation
    • listFiles

      @GET("/v1/files") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<File>> listFiles()
      List files

      RReturns a list of files that belong to the user's organization.

      Returns:
      A list of File objects.
    • uploadFile

      @Multipart @POST("/v1/files") io.reactivex.rxjava3.core.Single<File> uploadFile(@Part okhttp3.MultipartBody.Part file, @Part("purpose") okhttp3.RequestBody purpose)
      Upload file

      Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB.

      The size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants. See the Assistants Tools guide to learn more about the types of files supported. The Fine-tuning API only supports .jsonl files.

      Please contact us if you need to increase these storage limits.

      Parameters:
      file - The File object (not file name) to be uploaded.
      purpose - The intended purpose of the uploaded file. Use "fine-tune" for Fine-tuning and "assistants" for Assistants and Messages. This allows us to validate the format of the uploaded file is correct for fine-tuning.
      Returns:
      The uploaded File object.
    • deleteFile

      @DELETE("/v1/files/{file_id}") io.reactivex.rxjava3.core.Single<DeleteResponse> deleteFile(@Path("file_id") String fileId)
      Delete file

      Delete a file.

      Parameters:
      fileId - fileId
      Returns:
      Deletion status
    • retrieveFile

      @GET("/v1/files/{file_id}") io.reactivex.rxjava3.core.Single<File> retrieveFile(@Path("file_id") String fileId)
      Retrieve file

      Returns information about a specific file.

      Parameters:
      fileId - fileId
      Returns:
      The File object matching the specified ID.
    • retrieveFileContent

      @GET("/v1/files/{file_id}/content") io.reactivex.rxjava3.core.Single<String> retrieveFileContent(@Path("file_id") String fileId)
      Retrieve file content

      Returns the contents of the specified file.

      Parameters:
      fileId - The ID of the file to use for this request.
      Returns:
      The file content.
    • createFineTuningJob

      @POST("/v1/fine_tuning/jobs") io.reactivex.rxjava3.core.Single<FineTuningJob> createFineTuningJob(@Body CreateFineTuningJobRequest request)
      Create fine-tuning job

      Creates a job that fine-tunes a specified model from a given dataset.

      Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.

      Parameters:
      request - create fine tuning job request
      Returns:
      A FineTuningJob object.
    • cancelFineTuningJob

      @POST("/v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel") io.reactivex.rxjava3.core.Single<FineTuningJob> cancelFineTuningJob(@Path("fine_tuning_job_id") String fineTuningJobId)
      Cancel fine-tuning

      Immediately cancel a fine-tune job.

      Parameters:
      fineTuningJobId - The ID of the fine-tuning job to cancel.
      Returns:
      The cancelled FineTuningJob object.
    • retrieveFineTuningJob

      @GET("/v1/fine_tuning/jobs/{fine_tuning_job_id}") io.reactivex.rxjava3.core.Single<FineTuningJob> retrieveFineTuningJob(@Path("fine_tuning_job_id") String fineTuningJobId)
      Retrieve fine-tuning job

      Get info about a fine-tuning job.

      Parameters:
      fineTuningJobId - The ID of the fine-tuning job.
      Returns:
      The FineTuningJob object with the given ID.
    • listFineTuningEvents

      @GET("/v1/fine_tuning/jobs/{fine_tuning_job_id}/events") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<FineTuningJobEvent>> listFineTuningEvents(@Path("fine_tuning_job_id") String fineTuningJobId, @Query("after") String after, @Query("limit") Integer limit)
      List fine-tuning events

      Get status updates for a fine-tuning job.

      Parameters:
      fineTuningJobId - The ID of the fine-tuning job to get events for.
      after - Optional Identifier for the last event from the previous pagination request.
      limit - Optional Defaults to 20 Number of events to retrieve.
      Returns:
      A list of fine-tuning event objects.
    • createAssistant

      @POST("/v1/assistants") io.reactivex.rxjava3.core.Single<Assistant> createAssistant(@Body CreateAssistantRequest request)
      https://api.openai.com/v1/assistants

      Create an assistant with a model and instructions.

      Parameters:
      request - Request body
      Returns:
      An Assistant object.
    • retrieveAssistant

      @GET("/v1/assistants/{assistant_id}") io.reactivex.rxjava3.core.Single<Assistant> retrieveAssistant(@Path("assistant_id") String assistantId)
      https://api.openai.com/v1/assistants/{assistant_id}

      The assistant object matching the specified ID.

      Parameters:
      assistantId - The ID of the assistant to retrieve.
      Returns:
      The ID of the Assistant to retrieve.
    • modifyAssistant

      @POST("/v1/assistants/{assistant_id}") io.reactivex.rxjava3.core.Single<Assistant> modifyAssistant(@Path("assistant_id") String assistantId, @Body ModifyAssistantRequest request)
      https://api.openai.com/v1/assistants/{assistant_id}

      Modifies an assistant.

      Parameters:
      assistantId - The ID of the assistant to modify.
      request - Request body
      Returns:
      The modified Assistant object.
    • deleteAssistant

      @DELETE("/v1/assistants/{assistant_id}") io.reactivex.rxjava3.core.Single<DeleteResponse> deleteAssistant(@Path("assistant_id") String assistantId)
      https://api.openai.com/v1/assistants/{assistant_id}

      Delete an assistant.

      Parameters:
      assistantId - The ID of the assistant to delete.
      Returns:
      Deletion status
    • listAssistants

      @GET("/v1/assistants") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<Assistant>> listAssistants(@Query("limit") Integer limit, @Query("order") String order, @Query("after") String after, @Query("before") String before)
      https://api.openai.com/v1/assistants

      Returns a list of assistants.

      Parameters:
      limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
      order - Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
      after - A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
      before - A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
      Returns:
      A list of Assistant objects.
    • createAssistantFile

      @POST("/v1/assistants/{assistant_id}/files") io.reactivex.rxjava3.core.Single<AssistantFile> createAssistantFile(@Path("assistant_id") String assistantId, @Body CreateAssistantFileRequest request)
      https://api.openai.com/v1/assistants/{assistant_id}/files

      Create assistant file

      Parameters:
      assistantId - The ID of the assistant for which to create a File.
      request - Request body
      Returns:
      An AssistantFile object.
    • retrieveAssistantFile

      @GET("/v1/assistants/{assistant_id}/files/{file_id}") io.reactivex.rxjava3.core.Single<AssistantFile> retrieveAssistantFile(@Path("assistant_id") String assistantId, @Path("file_id") String fileId)
      https://api.openai.com/v1/assistants/{assistant_id}/files/{file_id}

      Retrieve assistant file

      Parameters:
      assistantId - The ID of the assistant who the file belongs to.
      fileId - The ID of the file we're getting.
      Returns:
      The AssistantFile object matching the specified ID.
    • deleteAssistantFile

      @DELETE("/v1/assistants/{assistant_id}/files/{file_id}") io.reactivex.rxjava3.core.Single<DeleteResponse> deleteAssistantFile(@Path("assistant_id") String assistantId, @Path("file_id") String fileId)
      https://api.openai.com/v1/assistants/{assistant_id}/files/{file_id}

      Delete an assistant file.

      Parameters:
      assistantId - The ID of the assistant who the file belongs to.
      fileId - The ID of the file to delete.
      Returns:
      Deletion status
    • listAssistantFiles

      @GET("/v1/assistants/{assistant_id}/files") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<AssistantFile>> listAssistantFiles(@Path("assistant_id") String assistantId, @Query("limit") Integer limit, @Query("order") String order, @Query("after") String after, @Query("before") String before)
      https://api.openai.com/v1/assistants/{assistant_id}/files

      Returns a list of assistant files.

      Parameters:
      assistantId - The ID of the assistant the file belongs to.
      limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
      order - Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
      after - A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
      before - A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
      Returns:
      A list of AssistantFile objects.
    • createThread

      @POST("/v1/threads") io.reactivex.rxjava3.core.Single<Thread> createThread(@Body CreateThreadRequest request)
      https://api.openai.com/v1/threads

      Create thread

      Parameters:
      request - Request body
      Returns:
      An Thread object.
    • retrieveThread

      @GET("/v1/threads/{thread_id}") io.reactivex.rxjava3.core.Single<Thread> retrieveThread(@Path("thread_id") String threadId)
      https://api.openai.com/v1/threads/{thread_id}

      Retrieve thread

      Parameters:
      threadId - The ID of the thread to retrieve.
      Returns:
      The Thread object matching the specified ID.
    • modifyThread

      @POST("/v1/threads/{thread_id}") io.reactivex.rxjava3.core.Single<Thread> modifyThread(@Path("thread_id") String threadId, @Body ModifyThreadRequest request)
      https://api.openai.com/v1/threads/{thread_id}

      Modify thread

      Parameters:
      threadId - The ID of the thread to modify. Only the metadata can be modified.
      request - Request body
      Returns:
      The modified Thread object matching the specified ID.
    • deleteThread

      @DELETE("/v1/threads/{thread_id}") io.reactivex.rxjava3.core.Single<DeleteResponse> deleteThread(@Path("thread_id") String threadId)
      https://api.openai.com/v1/threads/{thread_id}

      Delete thread

      Parameters:
      threadId - The ID of the thread to delete.
      Returns:
      Deletion status
    • createThreadMessage

      @POST("/v1/threads/{thread_id}/messages") io.reactivex.rxjava3.core.Single<Message> createThreadMessage(@Path("thread_id") String threadId, @Body CreateMessageRequest request)
      https://api.openai.com/v1/threads/{thread_id}/messages

      Create message

      Parameters:
      threadId - The ID of the Thread to create a message for.
      request - Request body
      Returns:
      An Message object.
    • retrieveThreadMessage

      @GET("/v1/threads/{thread_id}/messages/{message_id}") io.reactivex.rxjava3.core.Single<Message> retrieveThreadMessage(@Path("thread_id") String threadId, @Path("message_id") String messageId)
      https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}

      Retrieve message

      Parameters:
      threadId - The ID of the Thread to which this message belongs.
      messageId - The ID of the message to retrieve.
      Returns:
      The Message object matching the specified ID.
    • modifyThreadMessage

      @POST("/v1/threads/{thread_id}/messages/{message_id}") io.reactivex.rxjava3.core.Single<Message> modifyThreadMessage(@Path("thread_id") String threadId, @Path("message_id") String messageId, @Body ModifyMessageRequest request)
      https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}

      Modify message

      Parameters:
      threadId - The ID of the thread to which this message belongs.
      messageId - The ID of the message to modify.
      request - Request body
      Returns:
      The modified Message object.
    • listThreadMessages

      @GET("/v1/threads/{thread_id}/messages") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<Message>> listThreadMessages(@Path("thread_id") String threadId, @Query("limit") Integer limit, @Query("order") String order, @Query("after") String after, @Query("before") String before)
      https://api.openai.com/v1/threads/{thread_id}/messages

      List messages

      Parameters:
      threadId - The ID of the Thread the messages belong to.
      limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
      order - Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
      after - A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
      before - A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
      Returns:
      A list of Message objects.
    • retrieveThreadMessageFile

      @GET("/v1/threads/{thread_id}/messages/{message_id}/files/{file_id}") io.reactivex.rxjava3.core.Single<MessageFile> retrieveThreadMessageFile(@Path("thread_id") String threadId, @Path("message_id") String messageId, @Path("file_id") String fileId)
      https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files/{file_id}

      Retrieves a message file.

      Parameters:
      threadId - The ID of the thread to which the message and File belong.
      messageId - The ID of the message the file belongs to.
      fileId - The ID of the file being retrieved.
      Returns:
      The MessageFile object.
    • listThreadMessageFiles

      @GET("/v1/threads/{thread_id}/messages") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<MessageFile>> listThreadMessageFiles(@Path("thread_id") String threadId, @Path("message_id") String messageId, @Query("limit") Integer limit, @Query("order") String order, @Query("after") String after, @Query("before") String before)
      https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files

      Returns a list of message files.

      Parameters:
      threadId - The ID of the thread that the message and files belong to.
      messageId - The ID of the message that the files belongs to.
      limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
      order - Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
      after - A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
      before - A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
      Returns:
      A list of MessageFile objects.
    • createThreadRun

      @POST("/v1/threads/{thread_id}/runs") io.reactivex.rxjava3.core.Single<Run> createThreadRun(@Path("thread_id") String threadId, @Body CreateRunRequest request)
      https://api.openai.com/v1/threads/{thread_id}/runs

      Create a run.

      Parameters:
      threadId - The ID of the thread to run.
      request - Request body
      Returns:
      An Run object.
    • retrieveThreadRun

      @GET("/v1/threads/{thread_id}/runs/{run_id}") io.reactivex.rxjava3.core.Single<Run> retrieveThreadRun(@Path("thread_id") String threadId, @Path("run_id") String runId)
      https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}

      Retrieves a run.

      Parameters:
      threadId - The ID of the Thread that was run.
      runId - The ID of the run to retrieve.
      Returns:
      The Run object matching the specified ID.
    • modifyThreadRun

      @POST("/v1/threads/{thread_id}/runs/{run_id}") io.reactivex.rxjava3.core.Single<Run> modifyThreadRun(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body ModifyRunRequest request)
      https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}

      Modify message

      Parameters:
      threadId - The ID of the Thread that was run.
      runId - The ID of the run to modify.
      request - Request body
      Returns:
      The modified Run object.
    • listThreadRuns

      @GET("/v1/threads/{thread_id}/runs") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<Run>> listThreadRuns(@Path("thread_id") String threadId, @Query("limit") Integer limit, @Query("order") String order, @Query("after") String after, @Query("before") String before)
      https://api.openai.com/v1/threads/{thread_id}/runs

      List messages

      Parameters:
      threadId - The ID of the Thread the messages belong to.
      limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
      order - Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
      after - A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
      before - A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
      Returns:
      A list of Run objects.
    • submitToolOutputs

      @GET("/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs") io.reactivex.rxjava3.core.Single<Run> submitToolOutputs(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body SubmitToolOutputsRequest request)
      https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs
      Parameters:
      threadId - The ID of the Thread to which this run belongs.
      runId - The ID of the run that requires the tool output submission.
      request - Request body
      Returns:
      The modified Run object matching the specified ID.
    • cancelThreadRun

      @GET("/v1/threads/{thread_id}/runs/{run_id}/cancel") io.reactivex.rxjava3.core.Single<Run> cancelThreadRun(@Path("thread_id") String threadId, @Path("run_id") String runId)
      https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/cancel

      Cancels a run that is in_progress.

      Parameters:
      threadId - The ID of the thread to which this run belongs.
      runId - The ID of the run to cancel.
      Returns:
      The modified Run object matching the specified ID.
    • createThreadAndRun

      io.reactivex.rxjava3.core.Single<Run> createThreadAndRun(@Body CreateThreadAndRunRequest request)
      https://api.openai.com/v1/threads/runs

      Create a thread and run it in one request.

      Parameters:
      request - Request body
      Returns:
      A Run object.
    • retrieveThreadRunStep

      @GET("/v1/threads/{thread_id}/runs/{run_id}/steps/{step_id}") io.reactivex.rxjava3.core.Single<RunStep> retrieveThreadRunStep(@Path("thread_id") String threadId, @Path("run_id") String runId, @Path("step_id") String stepId)
      https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps/{step_id}

      Retrieves a run step.

      Parameters:
      threadId - The ID of the thread to which the run and run step belongs.
      runId - The ID of the run to which the run step belongs.
      stepId - The ID of the run step to retrieve.
      Returns:
      The RunStep object matching the specified ID.
    • listThreadRunSteps

      @GET("/v1/threads/{thread_id}/runs/{run_id}/steps") io.reactivex.rxjava3.core.Single<OpenAiApiListResponse<RunStep>> listThreadRunSteps(@Path("thread_id") String threadId, @Path("run_id") String runId, @Query("limit") Integer limit, @Query("order") String order, @Query("after") String after, @Query("before") String before)
      https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps

      List run steps

      Parameters:
      threadId - The ID of the Thread the messages belong to.
      runId - The ID of the run steps belong to.
      limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
      order - Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
      after - A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
      before - A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
      Returns:
      A list of RunStep objects.