The OpenAI API can be applied to virtually any task that involves understanding or generating natural language or code. We offer a spectrum of models with different levels of power suitable for different tasks, as well as the ability to fine-tune your own custom models. These models can be used for everything from content generation to semantic search and classification.
Install the SDK by adding the following dependency in your project's pom.xml file:
<dependency>
<groupId>io.sdks</groupId>
<artifactId>apimatic-open-api-sdk</artifactId>
<version>1.0.0</version>
</dependency>You can also view the package at: https://central.sonatype.com/artifact/io.sdks/apimatic-open-api-sdk/1.0.0
The generated code and the server can be tested using automatically generated test cases. JUnit is used as the testing framework and test runner.
In Eclipse, for running the tests do the following:
- Select the project OpenAILib from the package explorer.
- Select
Run -> Run as -> JUnit Testor useAlt + Shift + Xfollowed byTto run the Tests.
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
|---|---|---|
| environment | Environment |
The API environment. Default: Environment.PRODUCTION |
| httpClientConfig | Consumer<HttpClientConfiguration.Builder> |
Set up Http Client Configuration instance. |
| bearerAuthCredentials | BearerAuthCredentials |
The Credentials Setter for OAuth 2 Bearer token |
The API client can be initialized as follows:
import com.openai.api.Environment;
import com.openai.api.OpenAIClient;
import com.openai.api.authentication.BearerAuthModel;
import com.openai.api.exceptions.ApiException;
import java.io.IOException;
public class Program {
public static void main(String[] args) {
OpenAIClient client = new OpenAIClient.Builder()
.httpClientConfig(configBuilder -> configBuilder
.timeout(0))
.bearerAuthCredentials(new BearerAuthModel.Builder(
"AccessToken"
)
.build())
.environment(Environment.PRODUCTION)
.build();
}
}This API uses the following authentication schemes.
- Configuration Interface
- HttpClientConfiguration
- HttpClientConfiguration.Builder
- HttpProxyConfiguration
- HttpProxyConfiguration.Builder