Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create ChatKit session

ChatSession beta().chatkit().sessions().create(SessionCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/chatkit/sessions

Create a ChatKit session.

ParametersExpand Collapse
SessionCreateParams params
String user

A free-form string that identifies your end user; ensures this Session can access other objects that have the same user scope.

minLength1

Workflow that powers the session.

Optional<ChatSessionChatKitConfigurationParam> chatkitConfiguration

Optional overrides for ChatKit runtime configuration features

Optional<ChatSessionExpiresAfterParam> expiresAfter

Optional override for session expiration timing in seconds from creation. Defaults to 10 minutes.

Optional<ChatSessionRateLimitsParam> rateLimits

Optional override for per-minute request limits. When omitted, defaults to 10.

ReturnsExpand Collapse
class ChatSession:

Represents a ChatKit session and its resolved configuration.

String id

Identifier for the ChatKit session.

ChatSessionChatKitConfiguration chatkitConfiguration

Resolved ChatKit feature configuration for the session.

String clientSecret

Ephemeral client secret that authenticates session requests.

long expiresAt

Unix timestamp (in seconds) for when the session expires.

formatunixtime
long maxRequestsPer1Minute

Convenience copy of the per-minute request limit.

JsonValue; object_ "chatkit.session"constant"chatkit.session"constant

Type discriminator that is always chatkit.session.

Resolved rate limit values.

Current lifecycle state of the session.

String user

User identifier associated with the session.

Workflow metadata for the session.

Create ChatKit session

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);
    }
}
{
  "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"
}
Returns Examples
{
  "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"
}