All URIs are relative to https://api.openai.com/v1
Method | HTTP request | Description |
---|---|---|
cancelBatch | POST /batches/{batch_id}/cancel | Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file. |
createBatch | POST /batches | Creates and executes a batch from an uploaded file of requests |
listBatches | GET /batches | List your organization's batches. |
retrieveBatch | GET /batches/{batch_id} | Retrieves a batch. |
Batch cancelBatch(batchId)
Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.
// 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.BatchApi;
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");
BatchApi apiInstance = new BatchApi(defaultClient);
String batchId = "batchId_example"; // String | The ID of the batch to cancel.
try {
Batch result = apiInstance.cancelBatch(batchId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BatchApi#cancelBatch");
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 |
---|---|---|---|
batchId | String | The ID of the batch to cancel. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch is cancelling. Returns the cancelling batch's details. | - |
Batch createBatch(createBatchRequest)
Creates and executes a batch from an uploaded file of requests
// 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.BatchApi;
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");
BatchApi apiInstance = new BatchApi(defaultClient);
CreateBatchRequest createBatchRequest = new CreateBatchRequest(); // CreateBatchRequest |
try {
Batch result = apiInstance.createBatch(createBatchRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BatchApi#createBatch");
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 |
---|---|---|---|
createBatchRequest | CreateBatchRequest |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch created successfully. | - |
ListBatchesResponse listBatches(after, limit)
List your organization's batches.
// 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.BatchApi;
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");
BatchApi apiInstance = new BatchApi(defaultClient);
String after = "after_example"; // String | 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.
Integer limit = 20; // Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
try {
ListBatchesResponse result = apiInstance.listBatches(after, limit);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BatchApi#listBatches");
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 |
---|---|---|---|
after | String | 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. | [optional] |
limit | Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. | [optional] [default to 20] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch listed successfully. | - |
Batch retrieveBatch(batchId)
Retrieves a batch.
// 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.BatchApi;
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");
BatchApi apiInstance = new BatchApi(defaultClient);
String batchId = "batchId_example"; // String | The ID of the batch to retrieve.
try {
Batch result = apiInstance.retrieveBatch(batchId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BatchApi#retrieveBatch");
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 |
---|---|---|---|
batchId | String | The ID of the batch to retrieve. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch retrieved successfully. | - |