codecamp

OpenAI 获取 ChatKit 线程

get /chatkit/threads/{thread_id}

按标识符获取 ChatKit 线程。

路径参数

  • thread_id: string

要获取的 ChatKit 线程标识符。

返回值

  • ChatKitThread object { id, created_at, object, 3 more }

ChatKit 线程及其当前状态。

  • id: string

线程的标识符。

  • created_at: integer

线程创建时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: "chatkit.thread" (default: "chatkit.thread")

对象类型,固定为 chatkit.thread。

  • "chatkit.thread"

  • status: Active { type } or Locked { reason, type } or Closed { reason, type }

线程的当前状态。新建线程默认为 active。

  • Active object { type }

线程处于活动状态。

  • type: "active" (default: "active")

状态类型,固定为 active。

  • "active"

  • Locked object { reason, type }

线程已锁定,无法接收新输入。

  • reason: string or null

线程锁定的原因。没有记录原因时默认为 null。

  • type: "locked" (default: "locked")

状态类型,固定为 locked。

  • "locked"

  • Closed object { reason, type }

线程已关闭。

  • reason: string or null

线程关闭的原因。没有记录原因时默认为 null。

  • type: "closed" (default: "closed")

状态类型,固定为 closed。

  • "closed"

  • title: string or null

可供阅读的线程标题。尚未生成标题时默认为 null。

  • user: string

标识该线程所属终端用户的字符串。

请求示例

## 在服务端设置 OPENAI_API_KEY 环境变量。
## 将线程 ID 替换为需要读取的 ChatKit 线程 ID。
curl https://api.openai.com/v1/chatkit/threads/cthr_abc123 \
  -H "OpenAI-Beta: chatkit_beta=v1" \
  -H "Authorization: Bearer $OPENAI_API_KEY"

响应示例

{
  "id": "cthr_abc123",
  "object": "chatkit.thread",
  "title": "需升级处理的客户问题",
  "created_at": 1712345600,
  "status": {
    "type": "active"
  },
  "user": "user_123"
}

取得线程 ID 后,可列出 ChatKit 线程条目 查看消息等条目。

OpenAI 取消 ChatKit 会话
OpenAI 删除 ChatKit 线程
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

其他能力与进阶指南

Embeddings 接口参考

审计日志接口参考

项目管理及子资源接口参考

Agents 接口及子资源

Decisions 接口参考

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }