OpenAI 列出容器

2026-11-12 14:59 更新

列出容器

get /containers

列出容器。

查询参数

  • after: optional string

用于分页的游标。after 是用于标记列表位置的对象 ID。例如,列表请求返回 100 个对象,最后一个对象的 ID 为 obj_foo,则后续调用可传入 after=obj_foo 来获取下一页。

  • limit: optional integer (default: 20)

要返回的对象数量上限,取值范围为 1 至 100,默认为 20。

  • name: optional string

按容器名称筛选结果。

  • order: optional "asc" or "desc" (default: "desc")

按对象的 created_at 时间戳排序。asc 为升序,desc 为降序。

  • "asc"

  • "desc"

返回值

  • data: array of object { id, created_at, name, 6 more }

容器列表。

  • id: string

容器的唯一标识符。

  • created_at: integer

创建容器时的 Unix 时间戳,单位为秒。

format: unixtime

  • name: string

容器的名称。

  • object: string

此对象的类型。

  • status: string

容器的状态,例如 active(活动)或 deleted(已删除)。

  • expires_after: optional object { anchor, minutes }

容器将在此时间段后过期。 anchor 是计算过期时间的基准时刻。 minutes 表示自基准时刻起、容器过期前经过的分钟数。

  • anchor: optional "last_active_at"

计算过期时间的基准时刻。

  • "last_active_at"

  • minutes: optional integer

自基准时刻起、容器过期前经过的分钟数。

  • last_active_at: optional integer

容器最近一次活动的 Unix 时间戳,单位为秒。

format: unixtime

  • memory_limit: optional "1g" or "4g" or "16g" or "64g"

为容器配置的内存上限。

  • "1g"

  • "4g"

  • "16g"

  • "64g"

  • network_policy: optional object { type, allowed_domains }

容器的网络访问策略。

  • type: "allowlist" or "disabled"

网络策略模式。

  • "allowlist"

  • "disabled"

  • allowed_domains: optional array of string

type 为 allowlist 时允许出站访问的域名。

  • first_id: string

列表中第一个容器的 ID。

  • has_more: boolean

是否还有更多容器可用。

  • last_id: string

列表中最后一个容器的 ID。

  • object: "list"

返回对象的类型,必须为 list。

  • "list"

示例

## 从环境变量读取 API 密钥;运行前替换容器、文件和技能等示例 ID。
curl https://api.openai.com/v1/containers \
    -H "Authorization: Bearer $OPENAI_API_KEY"

200 响应示例

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "name": "name",
      "object": "object",
      "status": "status",
      "expires_after": {
        "anchor": "last_active_at",
        "minutes": 0
      },
      "last_active_at": 0,
      "memory_limit": "1g",
      "network_policy": {
        "type": "allowlist",
        "allowed_domains": [
          "string"
        ]
      }
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}

示例

## 从环境变量读取 API 密钥;运行前替换容器、文件和技能等示例 ID。
curl https://api.openai.com/v1/containers \
  -H "Authorization: Bearer $OPENAI_API_KEY"

响应示例

{
  "object": "list",
  "data": [
    {
        "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863",
        "object": "container",
        "created_at": 1747844794,
        "status": "running",
        "expires_after": {
            "anchor": "last_active_at",
            "minutes": 20
        },
        "last_active_at": 1747844794,
        "memory_limit": "4g",
        "name": "示例容器"
    }
  ],
  "first_id": "container_123",
  "last_id": "container_123",
  "has_more": false
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号