Skip to content

MuHamza30/open-api-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started with OpenAI

Introduction

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 Package

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

Test the SDK

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:

  1. Select the project OpenAILib from the package explorer.
  2. Select Run -> Run as -> JUnit Test or use Alt + Shift + X followed by T to run the Tests.

Initialize the API Client

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();

    }
}

Authorization

This API uses the following authentication schemes.

List of APIs

SDK Infrastructure

Configuration

HTTP

Utilities

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages