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
Theme

Create a ChatKit session

client.Beta.ChatKit.Sessions.New(ctx, body) (*ChatSession, error)
POST
/chatkit/sessions

Create a ChatKit session.

Create a ChatKit session

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient()
  chatSession, err := client.Beta.ChatKit.Sessions.New(context.TODO(), openai.BetaChatKitSessionNewParams{
    User: "user_123",
    Workflow: openai.ChatSessionWorkflowParam{
      ID: "workflow_alpha",
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatSession.ID)
}
Response example
{
  "id": "cksess_123",
  "object": "chatkit.session",
  "client_secret": "ek_example_00eyJleHBpcmVzX2F0IjogMTczNTY4OTYwMH0=",
  "expires_at": 1735689600,
  "workflow": {
    "id": "workflow_alpha",
    "version": null,
    "state_variables": null,
    "tracing": {
      "enabled": true
    }
  },
  "user": "user_123",
  "rate_limits": {
    "max_requests_per_1_minute": 10
  },
  "max_requests_per_1_minute": 10,
  "status": "active",
  "chatkit_configuration": {
    "automatic_thread_titling": {
      "enabled": true
    },
    "file_upload": {
      "enabled": false,
      "max_file_size": 512,
      "max_files": 10
    },
    "history": {
      "enabled": true,
      "recent_threads": null
    }
  }
}
Parameters
body BetaChatKitSessionNewParams
User param.Field[string]

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

minLength1
Workflow param.Field[ChatSessionWorkflowParamResp]

Workflow that powers the session.

ChatKitConfiguration param.Field[ChatSessionChatKitConfigurationParamResp]
Optional

Optional overrides for ChatKit runtime configuration features

ExpiresAfter param.Field[ChatSessionExpiresAfterParamResp]
Optional

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

RateLimits param.Field[ChatSessionRateLimitsParamResp]
Optional

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

Returns
type ChatSession struct{…}

Represents a ChatKit session and its resolved configuration.

ID string

Identifier for the ChatKit session.

ChatKitConfiguration ChatSessionChatKitConfiguration

Resolved ChatKit feature configuration for the session.

ClientSecret string

Ephemeral client secret that authenticates session requests.

ExpiresAt int64

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

formatunixtime
MaxRequestsPer1Minute int64

Convenience copy of the per-minute request limit.

Object ChatKitSession

Type discriminator that is always chatkit.session.

Resolved rate limit values.

Current lifecycle state of the session.

User string

User identifier associated with the session.

Workflow metadata for the session.

Returns Examples
Response example
{
  "id": "cksess_123",
  "object": "chatkit.session",
  "client_secret": "ek_example_00eyJleHBpcmVzX2F0IjogMTczNTY4OTYwMH0=",
  "expires_at": 1735689600,
  "workflow": {
    "id": "workflow_alpha",
    "version": null,
    "state_variables": null,
    "tracing": {
      "enabled": true
    }
  },
  "user": "user_123",
  "rate_limits": {
    "max_requests_per_1_minute": 10
  },
  "max_requests_per_1_minute": 10,
  "status": "active",
  "chatkit_configuration": {
    "automatic_thread_titling": {
      "enabled": true
    },
    "file_upload": {
      "enabled": false,
      "max_file_size": 512,
      "max_files": 10
    },
    "history": {
      "enabled": true,
      "recent_threads": null
    }
  }
}