ChatKit
Domain Types
ChatKit Workflow
-
class ChatKitWorkflow:Workflow metadata and state returned for the session.
-
String idIdentifier of the workflow backing the session.
-
Optional<StateVariables> stateVariablesState variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.
-
String -
boolean -
double
-
-
Tracing tracingTracing settings applied to the workflow.
-
boolean enabledIndicates whether tracing is enabled.
-
-
Optional<String> versionSpecific workflow version used for the session. Defaults to null when using the latest deployment.
-
Sessions
Cancel chat session
ChatSession beta().chatkit().sessions().cancel(SessionCancelParamsparams = SessionCancelParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
post /chatkit/sessions/{session_id}/cancel
Cancel an active ChatKit session and return its most recent metadata.
Cancelling prevents new requests from using the issued client secret.
Parameters
-
SessionCancelParams paramsOptional<String> sessionId
Returns
-
class ChatSession:Represents a ChatKit session and its resolved configuration.
-
String idIdentifier for the ChatKit session.
-
ChatSessionChatKitConfiguration chatkitConfigurationResolved ChatKit feature configuration for the session.
-
ChatSessionAutomaticThreadTitling automaticThreadTitlingAutomatic thread titling preferences.
-
boolean enabledWhether automatic thread titling is enabled.
-
-
ChatSessionFileUpload fileUploadUpload settings for the session.
-
boolean enabledIndicates if uploads are enabled for the session.
-
Optional<Long> maxFileSizeMaximum upload size in megabytes.
-
Optional<Long> maxFilesMaximum number of uploads allowed during the session.
-
-
ChatSessionHistory historyHistory retention configuration.
-
boolean enabledIndicates if chat history is persisted for the session.
-
Optional<Long> recentThreadsNumber of prior threads surfaced in history views. Defaults to null when all history is retained.
-
-
-
String clientSecretEphemeral client secret that authenticates session requests.
-
long expiresAtUnix timestamp (in seconds) for when the session expires.
-
long maxRequestsPer1MinuteConvenience copy of the per-minute request limit.
-
JsonValue; object_ "chatkit.session"constantType discriminator that is always
chatkit.session.CHATKIT_SESSION("chatkit.session")
-
ChatSessionRateLimits rateLimitsResolved rate limit values.
-
long maxRequestsPer1MinuteMaximum allowed requests per one-minute window.
-
-
ChatSessionStatus statusCurrent lifecycle state of the session.
-
ACTIVE("active") -
EXPIRED("expired") -
CANCELLED("cancelled")
-
-
String userUser identifier associated with the session.
-
ChatKitWorkflow workflowWorkflow metadata for the session.
-
String idIdentifier of the workflow backing the session.
-
Optional<StateVariables> stateVariablesState variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.
-
String -
boolean -
double
-
-
Tracing tracingTracing settings applied to the workflow.
-
boolean enabledIndicates whether tracing is enabled.
-
-
Optional<String> versionSpecific workflow version used for the session. Defaults to null when using the latest deployment.
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.sessions.SessionCancelParams;
import com.openai.models.beta.chatkit.threads.ChatSession;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ChatSession chatSession = client.beta().chatkit().sessions().cancel("cksess_123");
}
}
Response
{
"id": "id",
"chatkit_configuration": {
"automatic_thread_titling": {
"enabled": true
},
"file_upload": {
"enabled": true,
"max_file_size": 0,
"max_files": 0
},
"history": {
"enabled": true,
"recent_threads": 0
}
},
"client_secret": "client_secret",
"expires_at": 0,
"max_requests_per_1_minute": 0,
"object": "chatkit.session",
"rate_limits": {
"max_requests_per_1_minute": 0
},
"status": "active",
"user": "user",
"workflow": {
"id": "id",
"state_variables": {
"foo": "string"
},
"tracing": {
"enabled": true
},
"version": "version"
}
}
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.sessions.SessionCancelParams;
import com.openai.models.beta.chatkit.threads.ChatSession;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ChatSession chatSession = client.beta().chatkit().sessions().cancel("cksess_123");
}
}
Response
{
"id": "cksess_123",
"object": "chatkit.session",
"workflow": {
"id": "workflow_alpha",
"version": "1"
},
"scope": {
"customer_id": "cust_456"
},
"max_requests_per_1_minute": 30,
"ttl_seconds": 900,
"status": "cancelled",
"cancelled_at": 1712345678
}
Create ChatKit session
ChatSession beta().chatkit().sessions().create(SessionCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /chatkit/sessions
Create a ChatKit session.
Parameters
-
SessionCreateParams params-
String userA free-form string that identifies your end user; ensures this Session can access other objects that have the same
userscope. -
ChatSessionWorkflowParam workflowWorkflow that powers the session.
-
Optional<ChatSessionChatKitConfigurationParam> chatkitConfigurationOptional overrides for ChatKit runtime configuration features
-
Optional<ChatSessionExpiresAfterParam> expiresAfterOptional override for session expiration timing in seconds from creation. Defaults to 10 minutes.
-
Optional<ChatSessionRateLimitsParam> rateLimitsOptional override for per-minute request limits. When omitted, defaults to 10.
-
Returns
-
class ChatSession:Represents a ChatKit session and its resolved configuration.
-
String idIdentifier for the ChatKit session.
-
ChatSessionChatKitConfiguration chatkitConfigurationResolved ChatKit feature configuration for the session.
-
ChatSessionAutomaticThreadTitling automaticThreadTitlingAutomatic thread titling preferences.
-
boolean enabledWhether automatic thread titling is enabled.
-
-
ChatSessionFileUpload fileUploadUpload settings for the session.
-
boolean enabledIndicates if uploads are enabled for the session.
-
Optional<Long> maxFileSizeMaximum upload size in megabytes.
-
Optional<Long> maxFilesMaximum number of uploads allowed during the session.
-
-
ChatSessionHistory historyHistory retention configuration.
-
boolean enabledIndicates if chat history is persisted for the session.
-
Optional<Long> recentThreadsNumber of prior threads surfaced in history views. Defaults to null when all history is retained.
-
-
-
String clientSecretEphemeral client secret that authenticates session requests.
-
long expiresAtUnix timestamp (in seconds) for when the session expires.
-
long maxRequestsPer1MinuteConvenience copy of the per-minute request limit.
-
JsonValue; object_ "chatkit.session"constantType discriminator that is always
chatkit.session.CHATKIT_SESSION("chatkit.session")
-
ChatSessionRateLimits rateLimitsResolved rate limit values.
-
long maxRequestsPer1MinuteMaximum allowed requests per one-minute window.
-
-
ChatSessionStatus statusCurrent lifecycle state of the session.
-
ACTIVE("active") -
EXPIRED("expired") -
CANCELLED("cancelled")
-
-
String userUser identifier associated with the session.
-
ChatKitWorkflow workflowWorkflow metadata for the session.
-
String idIdentifier of the workflow backing the session.
-
Optional<StateVariables> stateVariablesState variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.
-
String -
boolean -
double
-
-
Tracing tracingTracing settings applied to the workflow.
-
boolean enabledIndicates whether tracing is enabled.
-
-
Optional<String> versionSpecific workflow version used for the session. Defaults to null when using the latest deployment.
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.sessions.SessionCreateParams;
import com.openai.models.beta.chatkit.threads.ChatSession;
import com.openai.models.beta.chatkit.threads.ChatSessionWorkflowParam;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
SessionCreateParams params = SessionCreateParams.builder()
.user("x")
.workflow(ChatSessionWorkflowParam.builder()
.id("id")
.build())
.build();
ChatSession chatSession = client.beta().chatkit().sessions().create(params);
}
}
Response
{
"id": "id",
"chatkit_configuration": {
"automatic_thread_titling": {
"enabled": true
},
"file_upload": {
"enabled": true,
"max_file_size": 0,
"max_files": 0
},
"history": {
"enabled": true,
"recent_threads": 0
}
},
"client_secret": "client_secret",
"expires_at": 0,
"max_requests_per_1_minute": 0,
"object": "chatkit.session",
"rate_limits": {
"max_requests_per_1_minute": 0
},
"status": "active",
"user": "user",
"workflow": {
"id": "id",
"state_variables": {
"foo": "string"
},
"tracing": {
"enabled": true
},
"version": "version"
}
}
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.sessions.SessionCreateParams;
import com.openai.models.beta.chatkit.threads.ChatSession;
import com.openai.models.beta.chatkit.threads.ChatSessionWorkflowParam;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
SessionCreateParams params = SessionCreateParams.builder()
.user("user")
.workflow(ChatSessionWorkflowParam.builder()
.id("id")
.build())
.build();
ChatSession chatSession = client.beta().chatkit().sessions().create(params);
}
}
Response
{
"client_secret": "chatkit_token_123",
"expires_at": 1735689600,
"workflow": {
"id": "workflow_alpha",
"version": "2024-10-01"
},
"scope": {
"project": "alpha",
"environment": "staging"
},
"max_requests_per_1_minute": 60,
"max_requests_per_session": 500,
"status": "active"
}
Threads
List ChatKit thread items
ThreadListItemsPage beta().chatkit().threads().listItems(ThreadListItemsParamsparams = ThreadListItemsParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /chatkit/threads/{thread_id}/items
List items that belong to a ChatKit thread.
Parameters
-
ThreadListItemsParams params-
Optional<String> threadId -
Optional<String> afterList items created after this thread item ID. Defaults to null for the first page.
-
Optional<String> beforeList items created before this thread item ID. Defaults to null for the newest results.
-
Optional<Long> limitMaximum number of thread items to return. Defaults to 20.
-
Optional<Order> orderSort order for results by creation time. Defaults to
desc.-
ASC("asc") -
DESC("desc")
-
-
Returns
-
class Data: A class that can be one of several variants.unionUser-authored messages within a thread.
-
class ChatKitThreadUserMessageItem:User-authored messages within a thread.
-
String idIdentifier of the thread item.
-
List<ChatKitAttachment> attachmentsAttachments associated with the user message. Defaults to an empty list.
-
String idIdentifier for the attachment.
-
String mimeTypeMIME type of the attachment.
-
String nameOriginal display name for the attachment.
-
Optional<String> previewUrlPreview URL for rendering the attachment inline.
-
Type typeAttachment discriminator.
-
IMAGE("image") -
FILE("file")
-
-
-
List<Content> contentOrdered content elements supplied by the user.
-
class InputText:Text block that a user contributed to the thread.
-
String textPlain-text content supplied by the user.
-
JsonValue; type "input_text"constantType discriminator that is always
input_text.INPUT_TEXT("input_text")
-
-
class QuotedText:Quoted snippet that the user referenced in their message.
-
String textQuoted text content.
-
JsonValue; type "quoted_text"constantType discriminator that is always
quoted_text.QUOTED_TEXT("quoted_text")
-
-
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
Optional<InferenceOptions> inferenceOptionsInference overrides applied to the message. Defaults to null when unset.
-
Optional<String> modelModel name that generated the response. Defaults to null when using the session default.
-
Optional<ToolChoice> toolChoicePreferred tool to invoke. Defaults to null when ChatKit should auto-select.
-
String idIdentifier of the requested tool.
-
-
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.user_message"constantCHATKIT_USER_MESSAGE("chatkit.user_message")
-
-
class ChatKitThreadAssistantMessageItem:Assistant-authored message within a thread.
-
String idIdentifier of the thread item.
-
List<ChatKitResponseOutputText> contentOrdered assistant response segments.
-
List<Annotation> annotationsOrdered list of annotations attached to the response text.
-
class File:Annotation that references an uploaded file.
-
Source sourceFile attachment referenced by the annotation.
-
String filenameFilename referenced by the annotation.
-
JsonValue; type "file"constantType discriminator that is always
file.FILE("file")
-
-
JsonValue; type "file"constantType discriminator that is always
filefor this annotation.FILE("file")
-
-
class Url:Annotation that references a URL.
-
Source sourceURL referenced by the annotation.
-
JsonValue; type "url"constantType discriminator that is always
url.URL("url")
-
String urlURL referenced by the annotation.
-
-
JsonValue; type "url"constantType discriminator that is always
urlfor this annotation.URL("url")
-
-
-
String textAssistant generated text.
-
JsonValue; type "output_text"constantType discriminator that is always
output_text.OUTPUT_TEXT("output_text")
-
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.assistant_message"constantType discriminator that is always
chatkit.assistant_message.CHATKIT_ASSISTANT_MESSAGE("chatkit.assistant_message")
-
-
class ChatKitWidgetItem:Thread item that renders a widget payload.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.widget"constantType discriminator that is always
chatkit.widget.CHATKIT_WIDGET("chatkit.widget")
-
String widgetSerialized widget payload rendered in the UI.
-
-
class ChatKitClientToolCall:Record of a client side tool invocation initiated by the assistant.
-
String idIdentifier of the thread item.
-
String argumentsJSON-encoded arguments that were sent to the tool.
-
String callIdIdentifier for the client tool call.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
String nameTool name that was invoked.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
Optional<String> outputJSON-encoded output captured from the tool. Defaults to null while execution is in progress.
-
Status statusExecution status for the tool call.
-
IN_PROGRESS("in_progress") -
COMPLETED("completed")
-
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.client_tool_call"constantType discriminator that is always
chatkit.client_tool_call.CHATKIT_CLIENT_TOOL_CALL("chatkit.client_tool_call")
-
-
class ChatKitTask:Task emitted by the workflow to show progress and status updates.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
Optional<String> headingOptional heading for the task. Defaults to null when not provided.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
Optional<String> summaryOptional summary that describes the task. Defaults to null when omitted.
-
TaskType taskTypeSubtype for the task.
-
CUSTOM("custom") -
THOUGHT("thought")
-
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.task"constantType discriminator that is always
chatkit.task.CHATKIT_TASK("chatkit.task")
-
-
class ChatKitTaskGroup:Collection of workflow tasks grouped together in the thread.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
List<Task> tasksTasks included in the group.
-
Optional<String> headingOptional heading for the grouped task. Defaults to null when not provided.
-
Optional<String> summaryOptional summary that describes the grouped task. Defaults to null when omitted.
-
Type typeSubtype for the grouped task.
-
CUSTOM("custom") -
THOUGHT("thought")
-
-
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.task_group"constantType discriminator that is always
chatkit.task_group.CHATKIT_TASK_GROUP("chatkit.task_group")
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ThreadListItemsPage;
import com.openai.models.beta.chatkit.threads.ThreadListItemsParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadListItemsPage page = client.beta().chatkit().threads().listItems("cthr_123");
}
}
Response
{
"data": [
{
"id": "id",
"attachments": [
{
"id": "id",
"mime_type": "mime_type",
"name": "name",
"preview_url": "https://example.com",
"type": "image"
}
],
"content": [
{
"text": "text",
"type": "input_text"
}
],
"created_at": 0,
"inference_options": {
"model": "model",
"tool_choice": {
"id": "id"
}
},
"object": "chatkit.thread_item",
"thread_id": "thread_id",
"type": "chatkit.user_message"
}
],
"first_id": "first_id",
"has_more": true,
"last_id": "last_id",
"object": "list"
}
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ThreadListItemsPage;
import com.openai.models.beta.chatkit.threads.ThreadListItemsParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadListItemsPage page = client.beta().chatkit().threads().listItems("cthr_123");
}
}
Response
{
"data": [
{
"id": "cthi_user_001",
"object": "chatkit.thread_item",
"type": "user_message",
"content": [
{
"type": "input_text",
"text": "I need help debugging an onboarding issue."
}
],
"attachments": []
},
{
"id": "cthi_assistant_002",
"object": "chatkit.thread_item",
"type": "assistant_message",
"content": [
{
"type": "output_text",
"text": "Let's start by confirming the workflow version you deployed."
}
]
}
],
"has_more": false,
"object": "list"
}
Retrieve ChatKit thread
ChatKitThread beta().chatkit().threads().retrieve(ThreadRetrieveParamsparams = ThreadRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /chatkit/threads/{thread_id}
Retrieve a ChatKit thread by its identifier.
Parameters
-
ThreadRetrieveParams paramsOptional<String> threadId
Returns
-
class ChatKitThread:Represents a ChatKit thread and its current status.
-
String idIdentifier of the thread.
-
long createdAtUnix timestamp (in seconds) for when the thread was created.
-
JsonValue; object_ "chatkit.thread"constantType discriminator that is always
chatkit.thread.CHATKIT_THREAD("chatkit.thread")
-
Status statusCurrent status for the thread. Defaults to
activefor newly created threads.-
JsonValue;-
JsonValue; type "active"constantStatus discriminator that is always
active.ACTIVE("active")
-
-
class Locked:Indicates that a thread is locked and cannot accept new input.
-
Optional<String> reasonReason that the thread was locked. Defaults to null when no reason is recorded.
-
JsonValue; type "locked"constantStatus discriminator that is always
locked.LOCKED("locked")
-
-
class Closed:Indicates that a thread has been closed.
-
Optional<String> reasonReason that the thread was closed. Defaults to null when no reason is recorded.
-
JsonValue; type "closed"constantStatus discriminator that is always
closed.CLOSED("closed")
-
-
-
Optional<String> titleOptional human-readable title for the thread. Defaults to null when no title has been generated.
-
String userFree-form string that identifies your end user who owns the thread.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ChatKitThread;
import com.openai.models.beta.chatkit.threads.ThreadRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ChatKitThread chatkitThread = client.beta().chatkit().threads().retrieve("cthr_123");
}
}
Response
{
"id": "cthr_def456",
"created_at": 1712345600,
"object": "chatkit.thread",
"status": {
"type": "active"
},
"title": "Demo feedback",
"user": "user_456"
}
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ChatKitThread;
import com.openai.models.beta.chatkit.threads.ThreadRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ChatKitThread chatkitThread = client.beta().chatkit().threads().retrieve("cthr_123");
}
}
Response
{
"id": "cthr_abc123",
"object": "chatkit.thread",
"title": "Customer escalation",
"items": {
"data": [
{
"id": "cthi_user_001",
"object": "chatkit.thread_item",
"type": "user_message",
"content": [
{
"type": "input_text",
"text": "I need help debugging an onboarding issue."
}
],
"attachments": []
},
{
"id": "cthi_assistant_002",
"object": "chatkit.thread_item",
"type": "assistant_message",
"content": [
{
"type": "output_text",
"text": "Let's start by confirming the workflow version you deployed."
}
]
}
],
"has_more": false
}
}
Delete ChatKit thread
ThreadDeleteResponse beta().chatkit().threads().delete(ThreadDeleteParamsparams = ThreadDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
delete /chatkit/threads/{thread_id}
Delete a ChatKit thread along with its items and stored attachments.
Parameters
-
ThreadDeleteParams paramsOptional<String> threadId
Returns
-
class ThreadDeleteResponse:Confirmation payload returned after deleting a thread.
-
String idIdentifier of the deleted thread.
-
boolean deletedIndicates that the thread has been deleted.
-
JsonValue; object_ "chatkit.thread.deleted"constantType discriminator that is always
chatkit.thread.deleted.CHATKIT_THREAD_DELETED("chatkit.thread.deleted")
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ThreadDeleteParams;
import com.openai.models.beta.chatkit.threads.ThreadDeleteResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadDeleteResponse thread = client.beta().chatkit().threads().delete("cthr_123");
}
}
Response
{
"id": "id",
"deleted": true,
"object": "chatkit.thread.deleted"
}
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chat_kit.threads.ThreadDeleteParams;
import com.openai.models.beta.chat_kit.threads.ThreadDeleteResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadDeleteResponse thread = client.beta().chat_kit().threads().delete("cthr_123");
}
}
List ChatKit threads
ThreadListPage beta().chatkit().threads().list(ThreadListParamsparams = ThreadListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /chatkit/threads
List ChatKit threads with optional pagination and user filters.
Parameters
-
ThreadListParams params-
Optional<String> afterList items created after this thread item ID. Defaults to null for the first page.
-
Optional<String> beforeList items created before this thread item ID. Defaults to null for the newest results.
-
Optional<Long> limitMaximum number of thread items to return. Defaults to 20.
-
Optional<Order> orderSort order for results by creation time. Defaults to
desc.-
ASC("asc") -
DESC("desc")
-
-
Optional<String> userFilter threads that belong to this user identifier. Defaults to null to return all users.
-
Returns
-
class ChatKitThread:Represents a ChatKit thread and its current status.
-
String idIdentifier of the thread.
-
long createdAtUnix timestamp (in seconds) for when the thread was created.
-
JsonValue; object_ "chatkit.thread"constantType discriminator that is always
chatkit.thread.CHATKIT_THREAD("chatkit.thread")
-
Status statusCurrent status for the thread. Defaults to
activefor newly created threads.-
JsonValue;-
JsonValue; type "active"constantStatus discriminator that is always
active.ACTIVE("active")
-
-
class Locked:Indicates that a thread is locked and cannot accept new input.
-
Optional<String> reasonReason that the thread was locked. Defaults to null when no reason is recorded.
-
JsonValue; type "locked"constantStatus discriminator that is always
locked.LOCKED("locked")
-
-
class Closed:Indicates that a thread has been closed.
-
Optional<String> reasonReason that the thread was closed. Defaults to null when no reason is recorded.
-
JsonValue; type "closed"constantStatus discriminator that is always
closed.CLOSED("closed")
-
-
-
Optional<String> titleOptional human-readable title for the thread. Defaults to null when no title has been generated.
-
String userFree-form string that identifies your end user who owns the thread.
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ThreadListPage;
import com.openai.models.beta.chatkit.threads.ThreadListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadListPage page = client.beta().chatkit().threads().list();
}
}
Response
{
"data": [
{
"id": "cthr_def456",
"created_at": 1712345600,
"object": "chatkit.thread",
"status": {
"type": "active"
},
"title": "Demo feedback",
"user": "user_456"
}
],
"first_id": "first_id",
"has_more": true,
"last_id": "last_id",
"object": "list"
}
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.chatkit.threads.ThreadListPage;
import com.openai.models.beta.chatkit.threads.ThreadListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ThreadListPage page = client.beta().chatkit().threads().list();
}
}
Response
{
"data": [
{
"id": "cthr_abc123",
"object": "chatkit.thread",
"title": "Customer escalation"
},
{
"id": "cthr_def456",
"object": "chatkit.thread",
"title": "Demo feedback"
}
],
"has_more": false,
"object": "list"
}
Domain Types
Chat Session
-
class ChatSession:Represents a ChatKit session and its resolved configuration.
-
String idIdentifier for the ChatKit session.
-
ChatSessionChatKitConfiguration chatkitConfigurationResolved ChatKit feature configuration for the session.
-
ChatSessionAutomaticThreadTitling automaticThreadTitlingAutomatic thread titling preferences.
-
boolean enabledWhether automatic thread titling is enabled.
-
-
ChatSessionFileUpload fileUploadUpload settings for the session.
-
boolean enabledIndicates if uploads are enabled for the session.
-
Optional<Long> maxFileSizeMaximum upload size in megabytes.
-
Optional<Long> maxFilesMaximum number of uploads allowed during the session.
-
-
ChatSessionHistory historyHistory retention configuration.
-
boolean enabledIndicates if chat history is persisted for the session.
-
Optional<Long> recentThreadsNumber of prior threads surfaced in history views. Defaults to null when all history is retained.
-
-
-
String clientSecretEphemeral client secret that authenticates session requests.
-
long expiresAtUnix timestamp (in seconds) for when the session expires.
-
long maxRequestsPer1MinuteConvenience copy of the per-minute request limit.
-
JsonValue; object_ "chatkit.session"constantType discriminator that is always
chatkit.session.CHATKIT_SESSION("chatkit.session")
-
ChatSessionRateLimits rateLimitsResolved rate limit values.
-
long maxRequestsPer1MinuteMaximum allowed requests per one-minute window.
-
-
ChatSessionStatus statusCurrent lifecycle state of the session.
-
ACTIVE("active") -
EXPIRED("expired") -
CANCELLED("cancelled")
-
-
String userUser identifier associated with the session.
-
ChatKitWorkflow workflowWorkflow metadata for the session.
-
String idIdentifier of the workflow backing the session.
-
Optional<StateVariables> stateVariablesState variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.
-
String -
boolean -
double
-
-
Tracing tracingTracing settings applied to the workflow.
-
boolean enabledIndicates whether tracing is enabled.
-
-
Optional<String> versionSpecific workflow version used for the session. Defaults to null when using the latest deployment.
-
-
Chat Session Automatic Thread Titling
-
class ChatSessionAutomaticThreadTitling:Automatic thread title preferences for the session.
-
boolean enabledWhether automatic thread titling is enabled.
-
Chat Session ChatKit Configuration
-
class ChatSessionChatKitConfiguration:ChatKit configuration for the session.
-
ChatSessionAutomaticThreadTitling automaticThreadTitlingAutomatic thread titling preferences.
-
boolean enabledWhether automatic thread titling is enabled.
-
-
ChatSessionFileUpload fileUploadUpload settings for the session.
-
boolean enabledIndicates if uploads are enabled for the session.
-
Optional<Long> maxFileSizeMaximum upload size in megabytes.
-
Optional<Long> maxFilesMaximum number of uploads allowed during the session.
-
-
ChatSessionHistory historyHistory retention configuration.
-
boolean enabledIndicates if chat history is persisted for the session.
-
Optional<Long> recentThreadsNumber of prior threads surfaced in history views. Defaults to null when all history is retained.
-
-
Chat Session ChatKit Configuration Param
-
class ChatSessionChatKitConfigurationParam:Optional per-session configuration settings for ChatKit behavior.
-
Optional<AutomaticThreadTitling> automaticThreadTitlingConfiguration for automatic thread titling. When omitted, automatic thread titling is enabled by default.
-
Optional<Boolean> enabledEnable automatic thread title generation. Defaults to true.
-
-
Optional<FileUpload> fileUploadConfiguration for upload enablement and limits. When omitted, uploads are disabled by default (max_files 10, max_file_size 512 MB).
-
Optional<Boolean> enabledEnable uploads for this session. Defaults to false.
-
Optional<Long> maxFileSizeMaximum size in megabytes for each uploaded file. Defaults to 512 MB, which is the maximum allowable size.
-
Optional<Long> maxFilesMaximum number of files that can be uploaded to the session. Defaults to 10.
-
-
Optional<History> historyConfiguration for chat history retention. When omitted, history is enabled by default with no limit on recent_threads (null).
-
Optional<Boolean> enabledEnables chat users to access previous ChatKit threads. Defaults to true.
-
Optional<Long> recentThreadsNumber of recent ChatKit threads users have access to. Defaults to unlimited when unset.
-
-
Chat Session Expires After Param
-
class ChatSessionExpiresAfterParam:Controls when the session expires relative to an anchor timestamp.
-
JsonValue; anchor "created_at"constantBase timestamp used to calculate expiration. Currently fixed to
created_at.CREATED_AT("created_at")
-
long secondsNumber of seconds after the anchor when the session expires.
-
Chat Session File Upload
-
class ChatSessionFileUpload:Upload permissions and limits applied to the session.
-
boolean enabledIndicates if uploads are enabled for the session.
-
Optional<Long> maxFileSizeMaximum upload size in megabytes.
-
Optional<Long> maxFilesMaximum number of uploads allowed during the session.
-
Chat Session History
-
class ChatSessionHistory:History retention preferences returned for the session.
-
boolean enabledIndicates if chat history is persisted for the session.
-
Optional<Long> recentThreadsNumber of prior threads surfaced in history views. Defaults to null when all history is retained.
-
Chat Session Rate Limits
-
class ChatSessionRateLimits:Active per-minute request limit for the session.
-
long maxRequestsPer1MinuteMaximum allowed requests per one-minute window.
-
Chat Session Rate Limits Param
-
class ChatSessionRateLimitsParam:Controls request rate limits for the session.
-
Optional<Long> maxRequestsPer1MinuteMaximum number of requests allowed per minute for the session. Defaults to 10.
-
Chat Session Status
-
enum ChatSessionStatus:-
ACTIVE("active") -
EXPIRED("expired") -
CANCELLED("cancelled")
-
Chat Session Workflow Param
-
class ChatSessionWorkflowParam:Workflow reference and overrides applied to the chat session.
-
String idIdentifier for the workflow invoked by the session.
-
Optional<StateVariables> stateVariablesState variables forwarded to the workflow. Keys may be up to 64 characters, values must be primitive types, and the map defaults to an empty object.
-
String -
boolean -
double
-
-
Optional<Tracing> tracingOptional tracing overrides for the workflow invocation. When omitted, tracing is enabled by default.
-
Optional<Boolean> enabledWhether tracing is enabled during the session. Defaults to true.
-
-
Optional<String> versionSpecific workflow version to run. Defaults to the latest deployed version.
-
ChatKit Attachment
-
class ChatKitAttachment:Attachment metadata included on thread items.
-
String idIdentifier for the attachment.
-
String mimeTypeMIME type of the attachment.
-
String nameOriginal display name for the attachment.
-
Optional<String> previewUrlPreview URL for rendering the attachment inline.
-
Type typeAttachment discriminator.
-
IMAGE("image") -
FILE("file")
-
-
ChatKit Response Output Text
-
class ChatKitResponseOutputText:Assistant response text accompanied by optional annotations.
-
List<Annotation> annotationsOrdered list of annotations attached to the response text.
-
class File:Annotation that references an uploaded file.
-
Source sourceFile attachment referenced by the annotation.
-
String filenameFilename referenced by the annotation.
-
JsonValue; type "file"constantType discriminator that is always
file.FILE("file")
-
-
JsonValue; type "file"constantType discriminator that is always
filefor this annotation.FILE("file")
-
-
class Url:Annotation that references a URL.
-
Source sourceURL referenced by the annotation.
-
JsonValue; type "url"constantType discriminator that is always
url.URL("url")
-
String urlURL referenced by the annotation.
-
-
JsonValue; type "url"constantType discriminator that is always
urlfor this annotation.URL("url")
-
-
-
String textAssistant generated text.
-
JsonValue; type "output_text"constantType discriminator that is always
output_text.OUTPUT_TEXT("output_text")
-
ChatKit Thread
-
class ChatKitThread:Represents a ChatKit thread and its current status.
-
String idIdentifier of the thread.
-
long createdAtUnix timestamp (in seconds) for when the thread was created.
-
JsonValue; object_ "chatkit.thread"constantType discriminator that is always
chatkit.thread.CHATKIT_THREAD("chatkit.thread")
-
Status statusCurrent status for the thread. Defaults to
activefor newly created threads.-
JsonValue;-
JsonValue; type "active"constantStatus discriminator that is always
active.ACTIVE("active")
-
-
class Locked:Indicates that a thread is locked and cannot accept new input.
-
Optional<String> reasonReason that the thread was locked. Defaults to null when no reason is recorded.
-
JsonValue; type "locked"constantStatus discriminator that is always
locked.LOCKED("locked")
-
-
class Closed:Indicates that a thread has been closed.
-
Optional<String> reasonReason that the thread was closed. Defaults to null when no reason is recorded.
-
JsonValue; type "closed"constantStatus discriminator that is always
closed.CLOSED("closed")
-
-
-
Optional<String> titleOptional human-readable title for the thread. Defaults to null when no title has been generated.
-
String userFree-form string that identifies your end user who owns the thread.
-
ChatKit Thread Assistant Message Item
-
class ChatKitThreadAssistantMessageItem:Assistant-authored message within a thread.
-
String idIdentifier of the thread item.
-
List<ChatKitResponseOutputText> contentOrdered assistant response segments.
-
List<Annotation> annotationsOrdered list of annotations attached to the response text.
-
class File:Annotation that references an uploaded file.
-
Source sourceFile attachment referenced by the annotation.
-
String filenameFilename referenced by the annotation.
-
JsonValue; type "file"constantType discriminator that is always
file.FILE("file")
-
-
JsonValue; type "file"constantType discriminator that is always
filefor this annotation.FILE("file")
-
-
class Url:Annotation that references a URL.
-
Source sourceURL referenced by the annotation.
-
JsonValue; type "url"constantType discriminator that is always
url.URL("url")
-
String urlURL referenced by the annotation.
-
-
JsonValue; type "url"constantType discriminator that is always
urlfor this annotation.URL("url")
-
-
-
String textAssistant generated text.
-
JsonValue; type "output_text"constantType discriminator that is always
output_text.OUTPUT_TEXT("output_text")
-
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.assistant_message"constantType discriminator that is always
chatkit.assistant_message.CHATKIT_ASSISTANT_MESSAGE("chatkit.assistant_message")
-
ChatKit Thread Item List
-
class ChatKitThreadItemList:A paginated list of thread items rendered for the ChatKit API.
-
List<Data> dataA list of items
-
class ChatKitThreadUserMessageItem:User-authored messages within a thread.
-
String idIdentifier of the thread item.
-
List<ChatKitAttachment> attachmentsAttachments associated with the user message. Defaults to an empty list.
-
String idIdentifier for the attachment.
-
String mimeTypeMIME type of the attachment.
-
String nameOriginal display name for the attachment.
-
Optional<String> previewUrlPreview URL for rendering the attachment inline.
-
Type typeAttachment discriminator.
-
IMAGE("image") -
FILE("file")
-
-
-
List<Content> contentOrdered content elements supplied by the user.
-
class InputText:Text block that a user contributed to the thread.
-
String textPlain-text content supplied by the user.
-
JsonValue; type "input_text"constantType discriminator that is always
input_text.INPUT_TEXT("input_text")
-
-
class QuotedText:Quoted snippet that the user referenced in their message.
-
String textQuoted text content.
-
JsonValue; type "quoted_text"constantType discriminator that is always
quoted_text.QUOTED_TEXT("quoted_text")
-
-
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
Optional<InferenceOptions> inferenceOptionsInference overrides applied to the message. Defaults to null when unset.
-
Optional<String> modelModel name that generated the response. Defaults to null when using the session default.
-
Optional<ToolChoice> toolChoicePreferred tool to invoke. Defaults to null when ChatKit should auto-select.
-
String idIdentifier of the requested tool.
-
-
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.user_message"constantCHATKIT_USER_MESSAGE("chatkit.user_message")
-
-
class ChatKitThreadAssistantMessageItem:Assistant-authored message within a thread.
-
String idIdentifier of the thread item.
-
List<ChatKitResponseOutputText> contentOrdered assistant response segments.
-
List<Annotation> annotationsOrdered list of annotations attached to the response text.
-
class File:Annotation that references an uploaded file.
-
Source sourceFile attachment referenced by the annotation.
-
String filenameFilename referenced by the annotation.
-
JsonValue; type "file"constantType discriminator that is always
file.FILE("file")
-
-
JsonValue; type "file"constantType discriminator that is always
filefor this annotation.FILE("file")
-
-
class Url:Annotation that references a URL.
-
Source sourceURL referenced by the annotation.
-
JsonValue; type "url"constantType discriminator that is always
url.URL("url")
-
String urlURL referenced by the annotation.
-
-
JsonValue; type "url"constantType discriminator that is always
urlfor this annotation.URL("url")
-
-
-
String textAssistant generated text.
-
JsonValue; type "output_text"constantType discriminator that is always
output_text.OUTPUT_TEXT("output_text")
-
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.assistant_message"constantType discriminator that is always
chatkit.assistant_message.CHATKIT_ASSISTANT_MESSAGE("chatkit.assistant_message")
-
-
class ChatKitWidgetItem:Thread item that renders a widget payload.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.widget"constantType discriminator that is always
chatkit.widget.CHATKIT_WIDGET("chatkit.widget")
-
String widgetSerialized widget payload rendered in the UI.
-
-
class ChatKitClientToolCall:Record of a client side tool invocation initiated by the assistant.
-
String idIdentifier of the thread item.
-
String argumentsJSON-encoded arguments that were sent to the tool.
-
String callIdIdentifier for the client tool call.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
String nameTool name that was invoked.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
Optional<String> outputJSON-encoded output captured from the tool. Defaults to null while execution is in progress.
-
Status statusExecution status for the tool call.
-
IN_PROGRESS("in_progress") -
COMPLETED("completed")
-
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.client_tool_call"constantType discriminator that is always
chatkit.client_tool_call.CHATKIT_CLIENT_TOOL_CALL("chatkit.client_tool_call")
-
-
class ChatKitTask:Task emitted by the workflow to show progress and status updates.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
Optional<String> headingOptional heading for the task. Defaults to null when not provided.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
Optional<String> summaryOptional summary that describes the task. Defaults to null when omitted.
-
TaskType taskTypeSubtype for the task.
-
CUSTOM("custom") -
THOUGHT("thought")
-
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.task"constantType discriminator that is always
chatkit.task.CHATKIT_TASK("chatkit.task")
-
-
class ChatKitTaskGroup:Collection of workflow tasks grouped together in the thread.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
List<Task> tasksTasks included in the group.
-
Optional<String> headingOptional heading for the grouped task. Defaults to null when not provided.
-
Optional<String> summaryOptional summary that describes the grouped task. Defaults to null when omitted.
-
Type typeSubtype for the grouped task.
-
CUSTOM("custom") -
THOUGHT("thought")
-
-
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.task_group"constantType discriminator that is always
chatkit.task_group.CHATKIT_TASK_GROUP("chatkit.task_group")
-
-
-
Optional<String> firstIdThe ID of the first item in the list.
-
boolean hasMoreWhether there are more items available.
-
Optional<String> lastIdThe ID of the last item in the list.
-
JsonValue; object_ "list"constantThe type of object returned, must be
list.LIST("list")
-
ChatKit Thread User Message Item
-
class ChatKitThreadUserMessageItem:User-authored messages within a thread.
-
String idIdentifier of the thread item.
-
List<ChatKitAttachment> attachmentsAttachments associated with the user message. Defaults to an empty list.
-
String idIdentifier for the attachment.
-
String mimeTypeMIME type of the attachment.
-
String nameOriginal display name for the attachment.
-
Optional<String> previewUrlPreview URL for rendering the attachment inline.
-
Type typeAttachment discriminator.
-
IMAGE("image") -
FILE("file")
-
-
-
List<Content> contentOrdered content elements supplied by the user.
-
class InputText:Text block that a user contributed to the thread.
-
String textPlain-text content supplied by the user.
-
JsonValue; type "input_text"constantType discriminator that is always
input_text.INPUT_TEXT("input_text")
-
-
class QuotedText:Quoted snippet that the user referenced in their message.
-
String textQuoted text content.
-
JsonValue; type "quoted_text"constantType discriminator that is always
quoted_text.QUOTED_TEXT("quoted_text")
-
-
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
Optional<InferenceOptions> inferenceOptionsInference overrides applied to the message. Defaults to null when unset.
-
Optional<String> modelModel name that generated the response. Defaults to null when using the session default.
-
Optional<ToolChoice> toolChoicePreferred tool to invoke. Defaults to null when ChatKit should auto-select.
-
String idIdentifier of the requested tool.
-
-
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.user_message"constantCHATKIT_USER_MESSAGE("chatkit.user_message")
-
ChatKit Widget Item
-
class ChatKitWidgetItem:Thread item that renders a widget payload.
-
String idIdentifier of the thread item.
-
long createdAtUnix timestamp (in seconds) for when the item was created.
-
JsonValue; object_ "chatkit.thread_item"constantType discriminator that is always
chatkit.thread_item.CHATKIT_THREAD_ITEM("chatkit.thread_item")
-
String threadIdIdentifier of the parent thread.
-
JsonValue; type "chatkit.widget"constantType discriminator that is always
chatkit.widget.CHATKIT_WIDGET("chatkit.widget")
-
String widgetSerialized widget payload rendered in the UI.
-