All URIs are relative to https://api.openai.com/v1
Method | HTTP request | Description |
---|---|---|
createChatCompletion | POST /chat/completions | Creates a model response for the given chat conversation. |
CreateChatCompletionResponse createChatCompletion(createChatCompletionRequest)
Creates a model response for the given chat conversation.
// Import classes:
import com.github.ainoya.client.ApiClient;
import com.github.ainoya.client.ApiException;
import com.github.ainoya.client.Configuration;
import com.github.ainoya.client.auth.*;
import com.github.ainoya.client.models.*;
import com.github.ainoya.openai.client.api.ChatApi;
public class Example {
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");
ChatApi apiInstance = new ChatApi(defaultClient);
CreateChatCompletionRequest createChatCompletionRequest = new CreateChatCompletionRequest(); // CreateChatCompletionRequest |
try {
CreateChatCompletionResponse result = apiInstance.createChatCompletion(createChatCompletionRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ChatApi#createChatCompletion");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
createChatCompletionRequest | CreateChatCompletionRequest |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | OK | - |