./generate-api-client.sh vXX.XX.XX
This repository contains a Java client library for the OpenAI API, generated using the OpenAPI Generator tool. The library is based on the official OpenAPI specification provided by OpenAI, which can be found at openai/openai-openapi.
While attempting to generate the client library directly from the official OpenAPI spec file, several issues were encountered, primarily due to certain syntax elements like oneOf
that led to generation errors. To overcome these challenges, modifications were made to the original spec file to ensure successful client generation and functional integrity of the resulting Java client.
Several definitions in the spec file that caused errors during generation were identified and rectified. This included, but was not limited to, addressing issues with oneOf
syntax. It is important to note that these modifications might have led to some original parameters becoming unavailable. For transparency and comparison, the original API spec has been saved as openapi.orig.yaml
, and the modified file used for generation is openapi.yaml
.
To view the specific changes made, you can use the command: diff -Nru openapi.yaml openapi.orig.yaml
.
All automatically generated tests have been run and passed, ensuring the reliability of the modified spec.
It is acknowledged that with a better understanding of the openapi-generator
options, it might be possible to generate the client from the original spec without modifications. This aspect is currently under continuous review and exploration.
We encourage users and developers to contribute to this repository, especially in improving the generation process and enhancing the library. Any updates or fixes that enable the use of the original spec file without modifications would be particularly valuable.
This client library is an independent effort and is not officially affiliated with OpenAI. Users should exercise due diligence and refer to OpenAI's official documentation and API guidelines for accurate information.
OpenAI API
-
API version: 2.0.0
- Build date: 2024-05-14T09:44:36.597799Z[Etc/UTC]
The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
For more information, please visit [https://help.openai.com/](https://help.openai.com/)
Automatically generated by the OpenAPI Generator
Building the API client library requires:
- Java 1.8+ 2. Maven/Gradle
To install the API client library to your local Maven repository, simply execute:
mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deploy
Refer to the OSSRH Guide for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>com.github.ainoya</groupId>
<artifactId>openai-java-generated-client</artifactId>
<version>0.0.17</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
repositories {
mavenCentral() // Needed if the 'openai-java-generated-client' jar has been published to maven central.
mavenLocal() // Needed if the 'openai-java-generated-client' jar has been published to the local maven repo.
}
dependencies {
implementation "com.github.ainoya:openai-java-generated-client:0.0.17"
}
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/openai-java-generated-client-0.0.17.jar
target/lib/*.jar
Please follow the installation instruction and execute the following Java code:
import com.github.ainoya.client.*;
import com.github.ainoya.client.auth.*;
import com.github.ainoya.client.model.*;
import com.github.ainoya.openai.client.api.AssistantApi;
public class AssistantApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.openai.com/v1");
// Configure HTTP bearer authorization: ApiKeyAuth
HttpBearerAuth ApiKeyAuth = (HttpBearerAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setBearerToken("BEARER TOKEN");
AssistantApi apiInstance = new AssistantApi(defaultClient);
String assistantId = "assistantId_example"; // String | The ID of the assistant to modify.
ModifyAssistantRequest modifyAssistantRequest = new ModifyAssistantRequest(); // ModifyAssistantRequest |
try {
AssistantObject result = apiInstance.modifyAssistant(assistantId, modifyAssistantRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AssistantApi#modifyAssistant");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
All URIs are relative to https://api.openai.com/v1
Class | Method | HTTP request | Description |
---|---|---|---|
AssistantApi | modifyAssistant | POST /assistants/{assistant_id} | Modifies an assistant. |
AssistantsApi | cancelRun | POST /threads/{thread_id}/runs/{run_id}/cancel | Cancels a run that is `in_progress`. |
AssistantsApi | createAssistant | POST /assistants | Create an assistant with a model and instructions. |
AssistantsApi | createAssistantFile | POST /assistants/{assistant_id}/files | Create an assistant file by attaching a File to an assistant. |
AssistantsApi | createMessage | POST /threads/{thread_id}/messages | Create a message. |
AssistantsApi | createRun | POST /threads/{thread_id}/runs | Create a run. |
AssistantsApi | createThread | POST /threads | Create a thread. |
AssistantsApi | createThreadAndRun | POST /threads/runs | Create a thread and run it in one request. |
AssistantsApi | deleteAssistant | DELETE /assistants/{assistant_id} | Delete an assistant. |
AssistantsApi | deleteAssistantFile | DELETE /assistants/{assistant_id}/files/{file_id} | Delete an assistant file. |
AssistantsApi | deleteThread | DELETE /threads/{thread_id} | Delete a thread. |
AssistantsApi | getAssistant | GET /assistants/{assistant_id} | Retrieves an assistant. |
AssistantsApi | getAssistantFile | GET /assistants/{assistant_id}/files/{file_id} | Retrieves an AssistantFile. |
AssistantsApi | getMessage | GET /threads/{thread_id}/messages/{message_id} | Retrieve a message. |
AssistantsApi | getMessageFile | GET /threads/{thread_id}/messages/{message_id}/files/{file_id} | Retrieves a message file. |
AssistantsApi | getRun | GET /threads/{thread_id}/runs/{run_id} | Retrieves a run. |
AssistantsApi | getRunStep | GET /threads/{thread_id}/runs/{run_id}/steps/{step_id} | Retrieves a run step. |
AssistantsApi | getThread | GET /threads/{thread_id} | Retrieves a thread. |
AssistantsApi | listAssistantFiles | GET /assistants/{assistant_id}/files | Returns a list of assistant files. |
AssistantsApi | listAssistants | GET /assistants | Returns a list of assistants. |
AssistantsApi | listMessageFiles | GET /threads/{thread_id}/messages/{message_id}/files | Returns a list of message files. |
AssistantsApi | listMessages | GET /threads/{thread_id}/messages | Returns a list of messages for a given thread. |
AssistantsApi | listRunSteps | GET /threads/{thread_id}/runs/{run_id}/steps | Returns a list of run steps belonging to a run. |
AssistantsApi | listRuns | GET /threads/{thread_id}/runs | Returns a list of runs belonging to a thread. |
AssistantsApi | modifyMessage | POST /threads/{thread_id}/messages/{message_id} | Modifies a message. |
AssistantsApi | modifyRun | POST /threads/{thread_id}/runs/{run_id} | Modifies a run. |
AssistantsApi | modifyThread | POST /threads/{thread_id} | Modifies a thread. |
AssistantsApi | submitToolOuputsToRun | POST /threads/{thread_id}/runs/{run_id}/submit_tool_outputs | When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. |
AudioApi | createSpeech | POST /audio/speech | Generates audio from the input text. |
AudioApi | createTranscription | POST /audio/transcriptions | Transcribes audio into the input language. |
AudioApi | createTranslation | POST /audio/translations | Translates audio into English. |
ChatApi | createChatCompletion | POST /chat/completions | Creates a model response for the given chat conversation. |
CompletionsApi | createCompletion | POST /completions | Creates a completion for the provided prompt and parameters. |
EditsApi | createEdit | POST /edits | Creates a new edit for the provided input, instruction, and parameters. |
EmbeddingsApi | createEmbedding | POST /embeddings | Creates an embedding vector representing the input text. |
FilesApi | createFile | POST /files | Upload a file that can be used across various endpoints/features. The size of all the files uploaded by one organization can be up to 100 GB. The size of individual files for can be a maximum of 512MB. 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. |
FilesApi | deleteFile | DELETE /files/{file_id} | Delete a file. |
FilesApi | downloadFile | GET /files/{file_id}/content | Returns the contents of the specified file. |
FilesApi | listFiles | GET /files | Returns a list of files that belong to the user's organization. |
FilesApi | retrieveFile | GET /files/{file_id} | Returns information about a specific file. |
FineTunesApi | cancelFineTune | POST /fine-tunes/{fine_tune_id}/cancel | Immediately cancel a fine-tune job. |
FineTunesApi | createFineTune | POST /fine-tunes | 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. Learn more about fine-tuning |
FineTunesApi | listFineTuneEvents | GET /fine-tunes/{fine_tune_id}/events | Get fine-grained status updates for a fine-tune job. |
FineTunesApi | listFineTunes | GET /fine-tunes | List your organization's fine-tuning jobs |
FineTunesApi | retrieveFineTune | GET /fine-tunes/{fine_tune_id} | Gets info about the fine-tune job. Learn more about fine-tuning |
FineTuningApi | cancelFineTuningJob | POST /fine_tuning/jobs/{fine_tuning_job_id}/cancel | Immediately cancel a fine-tune job. |
FineTuningApi | createFineTuningJob | POST /fine_tuning/jobs | 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. Learn more about fine-tuning |
FineTuningApi | listFineTuningEvents | GET /fine_tuning/jobs/{fine_tuning_job_id}/events | Get status updates for a fine-tuning job. |
FineTuningApi | listPaginatedFineTuningJobs | GET /fine_tuning/jobs | List your organization's fine-tuning jobs |
FineTuningApi | retrieveFineTuningJob | GET /fine_tuning/jobs/{fine_tuning_job_id} | Get info about a fine-tuning job. Learn more about fine-tuning |
ImagesApi | createImage | POST /images/generations | Creates an image given a prompt. |
ImagesApi | createImageEdit | POST /images/edits | Creates an edited or extended image given an original image and a prompt. |
ImagesApi | createImageVariation | POST /images/variations | Creates a variation of a given image. |
ModelsApi | deleteModel | DELETE /models/{model} | Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. |
ModelsApi | listModels | GET /models | Lists the currently available models, and provides basic information about each one such as the owner and availability. |
ModelsApi | retrieveModel | GET /models/{model} | Retrieves a model instance, providing basic information about the model such as the owner and permissioning. |
ModerationsApi | createModeration | POST /moderations | Classifies if text violates OpenAI's Content Policy |
- AssistantFileObject
- AssistantObject
- AssistantObjectToolsInner
- AssistantToolsCode
- AssistantToolsFunction
- AssistantToolsRetrieval
- ChatCompletionFunctionCallOption
- ChatCompletionFunctions
- ChatCompletionMessageToolCall
- ChatCompletionMessageToolCallChunk
- ChatCompletionMessageToolCallChunkFunction
- ChatCompletionMessageToolCallFunction
- ChatCompletionNamedToolChoice
- ChatCompletionNamedToolChoiceFunction
- ChatCompletionRequestAssistantMessage
- ChatCompletionRequestAssistantMessageFunctionCall
- ChatCompletionRequestFunctionMessage
- ChatCompletionRequestMessage
- ChatCompletionRequestMessageContentPart
- ChatCompletionRequestMessageContentPartImage
- ChatCompletionRequestMessageContentPartImageImageUrl
- ChatCompletionRequestMessageContentPartText
- ChatCompletionRequestSystemMessage
- ChatCompletionRequestToolMessage
- ChatCompletionRequestUserMessage
- ChatCompletionRequestUserMessageContent
- ChatCompletionResponseMessage
- ChatCompletionRole
- ChatCompletionStreamResponseDelta
- ChatCompletionStreamResponseDeltaFunctionCall
- ChatCompletionTool
- ChatCompletionToolChoiceOption
- CompletionUsage
- CreateAssistantFileRequest
- CreateAssistantRequest
- CreateChatCompletionFunctionResponse
- CreateChatCompletionFunctionResponseChoicesInner
- CreateChatCompletionRequest
- CreateChatCompletionRequestFunctionCall
- CreateChatCompletionRequestResponseFormat
- CreateChatCompletionResponse
- CreateChatCompletionResponseChoicesInner
- CreateChatCompletionStreamResponse
- CreateChatCompletionStreamResponseChoicesInner
- CreateCompletionRequest
- CreateCompletionRequestModel
- CreateCompletionRequestStop
- CreateCompletionResponse
- CreateCompletionResponseChoicesInner
- CreateCompletionResponseChoicesInnerLogprobs
- CreateEditRequest
- CreateEditRequestModel
- CreateEditResponse
- CreateEditResponseChoicesInner
- CreateEmbeddingRequest
- CreateEmbeddingRequestInput
- CreateEmbeddingResponse
- CreateEmbeddingResponseUsage
- CreateFineTuneRequest
- CreateFineTuneRequestHyperparameters
- CreateFineTuningJobRequest
- CreateFineTuningJobRequestHyperparameters
- CreateImageEditRequestModel
- CreateImageRequest
- CreateMessageRequest
- CreateModerationRequest
- CreateModerationRequestInput
- CreateModerationResponse
- CreateModerationResponseResultsInner
- CreateModerationResponseResultsInnerCategories
- CreateModerationResponseResultsInnerCategoryScores
- CreateRunRequest
- CreateSpeechRequest
- CreateThreadAndRunRequest
- CreateThreadAndRunRequestToolsInner
- CreateThreadRequest
- CreateTranscriptionRequestModel
- CreateTranscriptionResponse
- CreateTranslationResponse
- DeleteAssistantFileResponse
- DeleteAssistantResponse
- DeleteFileResponse
- DeleteMessageResponse
- DeleteModelResponse
- DeleteThreadResponse
- Embedding
- Error
- ErrorResponse
- FineTune
- FineTuneEvent
- FineTuneHyperparams
- FineTuningJob
- FineTuningJobError
- FineTuningJobEvent
- FineTuningJobHyperparameters
- FunctionObject
- Image
- ImagesResponse
- ListAssistantFilesResponse
- ListAssistantsResponse
- ListFilesResponse
- ListFineTuneEventsResponse
- ListFineTunesResponse
- ListFineTuningJobEventsResponse
- ListMessageFilesResponse
- ListMessagesResponse
- ListModelsResponse
- ListPaginatedFineTuningJobsResponse
- ListRunStepsResponse
- ListRunsResponse
- ListThreadsResponse
- MessageContentImageFileObject
- MessageContentImageFileObjectImageFile
- MessageContentTextAnnotationsFileCitationObject
- MessageContentTextAnnotationsFileCitationObjectFileCitation
- MessageContentTextAnnotationsFilePathObject
- MessageContentTextAnnotationsFilePathObjectFilePath
- MessageContentTextObject
- MessageContentTextObjectText
- MessageContentTextObjectTextAnnotationsInner
- MessageFileObject
- MessageObject
- MessageObjectContentInner
- Model
- ModifyAssistantRequest
- ModifyMessageRequest
- ModifyRunRequest
- ModifyThreadRequest
- OpenAIFile
- RunObject
- RunObjectLastError
- RunObjectRequiredAction
- RunObjectRequiredActionSubmitToolOutputs
- RunStepDetailsMessageCreationObject
- RunStepDetailsMessageCreationObjectMessageCreation
- RunStepDetailsToolCallsCodeObject
- RunStepDetailsToolCallsCodeObjectCodeInterpreter
- RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsInner
- RunStepDetailsToolCallsCodeOutputImageObject
- RunStepDetailsToolCallsCodeOutputImageObjectImage
- RunStepDetailsToolCallsCodeOutputLogsObject
- RunStepDetailsToolCallsFunctionObject
- RunStepDetailsToolCallsFunctionObjectFunction
- RunStepDetailsToolCallsObject
- RunStepDetailsToolCallsObjectToolCallsInner
- RunStepDetailsToolCallsRetrievalObject
- RunStepObject
- RunStepObjectLastError
- RunStepObjectStepDetails
- RunToolCallObject
- RunToolCallObjectFunction
- SubmitToolOutputsRunRequest
- SubmitToolOutputsRunRequestToolOutputsInner
- ThreadObject
Authentication schemes defined for the API: ### ApiKeyAuth
- **Type**: HTTP Bearer Token authentication
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.