Cancel chat session
client.Beta.ChatKit.Sessions.Cancel(ctx, sessionID) (*ChatSession, error)
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.
Cancel chat 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.Cancel(context.TODO(), "cksess_123")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", chatSession.ID)
}
{
"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
}
Returns Examples
{
"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
}