OpenAI 容器资源与对象

2026-11-12 14:58 更新

容器

创建容器

post /containers

创建容器。

请求体参数

内容类型:application/json

  • name: string

要创建的容器的名称。

  • expires_after: optional object { anchor, minutes }

相对于 anchor 时间的容器过期设置。原文此处写“秒”,但本对象使用 minutes 字段;依照下方字段定义,该值的单位为分钟。

  • anchor: "last_active_at"

计算过期时间所用的时间基点。目前仅支持 last_active_at。

  • "last_active_at"

  • minutes: integer

  • file_ids: optional array of string

要复制到容器中的文件 ID。

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

容器的可选内存上限,默认为 1g。

  • "1g"

  • "4g"

  • "16g"

  • "64g"

  • network_policy: optional ContainerNetworkPolicyDisabled or ContainerNetworkPolicyAllowlist

容器的网络访问策略。

  • ContainerNetworkPolicyDisabled object { type }

  • type: "disabled" (default: "disabled")

禁用出站网络访问。此分支的值始终为 disabled。

  • "disabled"

  • ContainerNetworkPolicyAllowlist object { allowed_domains, type, domain_secrets }

  • allowed_domains: array of string

type 为 allowlist 时允许访问的域名列表。

minItems: 1

  • type: "allowlist" (default: "allowlist")

仅允许出站访问指定域名。此分支的值始终为 allowlist。

  • "allowlist"

  • domain_secrets: optional array of ContainerNetworkPolicyDomainSecret

可选的域名级密钥,用于允许列表中的域名。

minItems: 1

  • domain: string

与此密钥关联的域名。

minLength: 1

  • name: string

要为该域名注入的密钥名称。

minLength: 1

  • value: string

要为该域名注入的密钥值。

minLength: 1, maxLength: 10485760

  • skills: optional array of SkillReference or InlineSkill

可选的技能列表,支持通过 ID 引用或直接内联数据。

  • SkillReference object { skill_id, type, version }

  • skill_id: string

所引用技能的 ID。

minLength: 1, maxLength: 64

  • type: "skill_reference" (default: "skill_reference")

引用通过 /v1/skills 端点创建的技能。

  • "skill_reference"

  • version: optional string

可选的技能版本。使用正整数或 latest;省略时使用默认版本。

  • InlineSkill object { description, name, source, type }

  • description: string

技能的描述。

  • name: string

技能的名称。

  • source: InlineSkillSource

内联技能载荷。

  • data: string

以 Base64 编码的技能 ZIP 包。

minLength: 1, maxLength: 70254592

  • media_type: "application/zip" (default: "application/zip")

内联技能载荷的媒体类型,必须为 application/zip。

  • "application/zip"

  • type: "base64" (default: "base64")

内联技能来源的类型,必须为 base64。

  • "base64"

  • type: "inline" (default: "inline")

为本次请求定义内联技能。

  • "inline"

返回值

  • 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 时允许出站访问的域名。

示例

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

200 响应示例

{
  "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"
    ]
  }
}

示例

## 从环境变量读取 API 密钥;运行前替换容器、文件和技能等示例 ID。
curl https://api.openai.com/v1/containers \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "name": "示例容器",
        "memory_limit": "4g",
        "skills": [
          {
            "type": "skill_reference",
            "skill_id": "skill_4db6f1a2c9e73508b41f9da06e2c7b5f"
          },
          {
            "type": "skill_reference",
            "skill_id": "openai-spreadsheets",
            "version": "latest"
          }
        ],
        "network_policy": {
          "type": "allowlist",
          "allowed_domains": ["api.buildkite.com"]
        }
      }'

响应示例

{
    "id": "cntr_682e30645a488191b6363a0cbefc0f0a025ec61b66250591",
    "object": "container",
    "created_at": 1747857508,
    "status": "running",
    "expires_after": {
        "anchor": "last_active_at",
        "minutes": 20
    },
    "last_active_at": 1747857508,
    "network_policy": {
        "type": "allowlist",
        "allowed_domains": ["api.buildkite.com"]
    },
    "memory_limit": "4g",
    "name": "示例容器"
}

删除容器

delete /containers/{container_id}

删除容器。

路径参数

  • container_id: string

要删除的容器的 ID。

返回值

  • id: string

  • deleted: boolean

  • object: "container.deleted"

  • "container.deleted"

示例

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

200 响应示例

{
  "id": "id",
  "deleted": true,
  "object": "container.deleted"
}

示例

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

响应示例

{
    "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863",
    "object": "container.deleted",
    "deleted": true
}

列出容器

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
}

检索容器

get /containers/{container_id}

检索容器。

路径参数

  • container_id: string

返回值

  • 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 时允许出站访问的域名。

示例

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

200 响应示例

{
  "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"
    ]
  }
}

示例

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

响应示例

{
    "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": "示例容器"
}

领域类型

创建容器响应

  • ContainerCreateResponse 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 时允许出站访问的域名。

删除容器响应

  • ContainerDeleteResponse object { id, deleted, object }

  • id: string

  • deleted: boolean

  • object: "container.deleted"

  • "container.deleted"

列出容器响应

  • ContainerListResponse 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 时允许出站访问的域名。

检索容器响应

  • ContainerRetrieveResponse 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 时允许出站访问的域名。

容器文件

创建容器文件

post /containers/{container_id}/files

创建容器文件。

可以发送包含原始文件内容的 multipart/form-data 请求,也可以发送包含文件 ID 的 JSON 请求。

路径参数

  • container_id: string

请求体参数

内容类型:application/json

  • file: optional string

要上传的 File 对象,而不是文件名。

  • file_id: optional string

要创建的文件的名称。译注:原文如此,但此处参数名为 file_id,通过 JSON 引用已有文件时应传文件 ID,不应传文件名。

返回值

  • id: string

文件的唯一标识符。

  • bytes: integer

文件大小,单位为字节。

  • container_id: string

此文件所属的容器。

  • created_at: integer

创建文件时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: string

此对象的类型(container.file)。

  • path: string

文件在容器中的路径。

  • source: string

文件的来源,例如 user(用户)或 assistant(助手)。

示例

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

200 响应示例

{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "object",
  "path": "path",
  "source": "source"
}

示例

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

响应示例

{
  "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
  "object": "container.file",
  "created_at": 1747848842,
  "bytes": 880,
  "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
  "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
  "source": "user"
}

删除容器文件

delete /containers/{container_id}/files/{file_id}

删除容器文件。

路径参数

  • container_id: string

  • file_id: string

返回值

  • id: string

  • deleted: boolean

  • object: "container.file.deleted"

  • "container.file.deleted"

示例

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

200 响应示例

{
  "id": "id",
  "deleted": true,
  "object": "container.file.deleted"
}

示例

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

响应示例

{
    "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
    "object": "container.file.deleted",
    "deleted": true
}

列出容器文件

get /containers/{container_id}/files

列出容器文件。

路径参数

  • container_id: string

查询参数

  • after: optional string

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

  • limit: optional integer (default: 20)

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

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

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

  • "asc"

  • "desc"

返回值

  • data: array of object { id, bytes, container_id, 4 more }

容器文件列表。

  • id: string

文件的唯一标识符。

  • bytes: integer

文件大小,单位为字节。

  • container_id: string

此文件所属的容器。

  • created_at: integer

创建文件时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: string

此对象的类型(container.file)。

  • path: string

文件在容器中的路径。

  • source: string

文件的来源,例如 user(用户)或 assistant(助手)。

  • first_id: string

列表中第一个文件的 ID。

  • has_more: boolean

是否还有更多文件可用。

  • last_id: string

列表中最后一个文件的 ID。

  • object: "list"

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

  • "list"

示例

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

200 响应示例

{
  "data": [
    {
      "id": "id",
      "bytes": 0,
      "container_id": "container_id",
      "created_at": 0,
      "object": "object",
      "path": "path",
      "source": "source"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}

示例

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

响应示例

{
    "object": "list",
    "data": [
        {
            "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
            "object": "container.file",
            "created_at": 1747848842,
            "bytes": 880,
            "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
            "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
            "source": "user"
        }
    ],
    "first_id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
    "has_more": false,
    "last_id": "cfile_682e0e8a43c88191a7978f477a09bdf5"
}

检索容器文件

get /containers/{container_id}/files/{file_id}

检索容器文件。

路径参数

  • container_id: string

  • file_id: string

返回值

  • id: string

文件的唯一标识符。

  • bytes: integer

文件大小,单位为字节。

  • container_id: string

此文件所属的容器。

  • created_at: integer

创建文件时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: string

此对象的类型(container.file)。

  • path: string

文件在容器中的路径。

  • source: string

文件的来源,例如 user(用户)或 assistant(助手)。

示例

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

200 响应示例

{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "object",
  "path": "path",
  "source": "source"
}

示例

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

响应示例

{
    "id": "cfile_682e0e8a43c88191a7978f477a09bdf5",
    "object": "container.file",
    "created_at": 1747848842,
    "bytes": 880,
    "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04",
    "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json",
    "source": "user"
}

领域类型

创建文件响应

  • FileCreateResponse object { id, bytes, container_id, 4 more }

  • id: string

文件的唯一标识符。

  • bytes: integer

文件大小,单位为字节。

  • container_id: string

此文件所属的容器。

  • created_at: integer

创建文件时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: string

此对象的类型(container.file)。

  • path: string

文件在容器中的路径。

  • source: string

文件的来源,例如 user(用户)或 assistant(助手)。

删除文件响应

  • FileDeleteResponse object { id, deleted, object }

  • id: string

  • deleted: boolean

  • object: "container.file.deleted"

  • "container.file.deleted"

列出文件响应

  • FileListResponse object { id, bytes, container_id, 4 more }

  • id: string

文件的唯一标识符。

  • bytes: integer

文件大小,单位为字节。

  • container_id: string

此文件所属的容器。

  • created_at: integer

创建文件时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: string

此对象的类型(container.file)。

  • path: string

文件在容器中的路径。

  • source: string

文件的来源,例如 user(用户)或 assistant(助手)。

检索文件响应

  • FileRetrieveResponse object { id, bytes, container_id, 4 more }

  • id: string

文件的唯一标识符。

  • bytes: integer

文件大小,单位为字节。

  • container_id: string

此文件所属的容器。

  • created_at: integer

创建文件时的 Unix 时间戳,单位为秒。

format: unixtime

  • object: string

此对象的类型(container.file)。

  • path: string

文件在容器中的路径。

  • source: string

文件的来源,例如 user(用户)或 assistant(助手)。

文件内容

检索容器文件内容

get /containers/{container_id}/files/{file_id}/content

检索容器文件内容。

路径参数

  • container_id: string

  • file_id: string

返回值

file

示例

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

示例

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

响应示例

(文件的二进制内容)
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号