Threads Beta
Note
Please build the client before calling, the build code is as follows:
OpenAiClient client = OpenAiClient.builder()
.apiHost("https://api.openai.com")
.apiKey(System.getProperty("openai.token"))
.build();
System.getProperty("openai.token")
is the key to access the API authorization.
Create thread
ThreadEntity configure = ThreadEntity.builder()
.build();
client.createThread(configure);
Returns:
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699012949,
"metadata": {}
}
Retrieve thread
String threadId = "thread_lsfBRIATCECds5WYLVXnVcpU";
client.retrieveThread(threadId);
Returns:
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699014083,
"metadata": {}
}
Modify thread
String threadId = "thread_lsfBRIATCECds5WYLVXnVcpU";
ThreadEntity configure = ThreadEntity.builder()
.build();
client.updateThread(threadId, configure);
Returns:
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699014083,
"metadata": {}
}
Delete thread
String threadId = "thread_lsfBRIATCECds5WYLVXnVcpU";
client.deleteThread(threadId);
Returns:
{
"id": "thread_abc123",
"object": "thread.deleted",
"deleted": true
}