OpenAI 获取智能体环境模板

2026-11-18 17:53 更新

get /agents/environments/templates/{environment_template_id}

获取可复用的环境配置。响应省略机密值。参见复用托管配置。

路径参数

  • environment_template_id: string

可复用的环境模板 ID。

minLength: 0, maxLength: 1048576

返回值

  • EnvironmentTemplate object { id, capability_directories, created_at, 9 more }

可复用的配置,用于为每个会话创建新的 OpenAI 托管环境。

  • id: string

可复用的环境模板 ID。

minLength: 0

  • capability_directories: array of string

用于向智能体提供能力的目录。

minItems: 0, maxItems: 2000

  • created_at: integer

模板创建时的 Unix 时间戳,单位为秒。

format: int64

  • desktop: object { enabled }

每个 OpenAI 托管环境的桌面配置。

  • enabled: boolean

环境是否配置桌面及浏览器代理。

  • files: array of FileID { file_id, path, type } or Inline { path, size_bytes, type }

可返回的文件元数据,省略文件内容和会话范围的文件 ID。

minItems: 0, maxItems: 50

  • FileID object { file_id, path, type }

项目范围内的 Files API 引用,每个会话独立解析。

  • file_id: string

已上传文件的 ID。

minLength: 0

  • path: string

文件在环境内的绝对路径。

minLength: 0

  • type: "file_id" (default: "file_id")

对象类型,固定为 file_id。

  • "file_id"

  • Inline object { path, size_bytes, type }

机密内联文件内容的元数据。

  • path: string

文件在环境内的绝对路径。

minLength: 0

  • size_bytes: integer

内联文件解码后的大小,单位为字节。

format: int64, minimum: 0

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

对象类型,固定为 inline。

  • "inline"

  • name: string or null

模板的可选显示名称。

minLength: 0

  • network: object { access, allowed_domains }

每个 OpenAI 托管环境的运行时网络访问配置。

  • access: "enabled" or "disabled" or "restricted"

环境的网络访问模式。

  • "enabled"

允许不受限制的网络访问。

  • "disabled"

关闭网络访问。

  • "restricted"

应用配置的域名访问限制。

  • allowed_domains: array of string

网络访问受限时,环境可以访问的域名。

minItems: 0, maxItems: 2000

  • object: "agent.environment.template" (default: "agent.environment.template")

对象类型,固定为 agent.environment.template。

  • "agent.environment.template"

  • packages: object { npm, python, system }

每次新建 OpenAI 托管环境时安装的软件包。

  • npm: array of string

在环境中全局安装的 npm 软件包。

minItems: 0, maxItems: 16384

  • python: array of string

已安装到环境中的 Python 软件包。

minItems: 0, maxItems: 16384

  • system: array of string

已安装到环境中的系统软件包。

minItems: 0, maxItems: 16384

  • plugins: array of HostedPlugin

可返回的插件元数据,省略内联归档内容。

minItems: 0, maxItems: 32

  • description: string

已安装插件的描述。

minLength: 0

  • name: string

已安装插件的名称。

minLength: 0

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

对象类型,固定为 inline。

  • "inline"

  • skills: array of SkillReference { skill_id, type, version } or Inline { description, name, type }

可返回的技能元数据,保留尚未解析的版本选择值。

minItems: 0, maxItems: 200

  • SkillReference object { skill_id, type, version }

每次启动会话时都通过 Skills API 重新解析的技能。

  • skill_id: string

引用的技能 ID。

minLength: 0

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

对象类型,固定为 skill_reference。

  • "skill_reference"

  • version: string or null

请求的版本选择值,包含 latest 选项。

minLength: 0

  • Inline object { description, name, type }

可以安全返回的内联技能归档元数据。

  • description: string

SKILL.md 中声明的技能描述。

minLength: 0

  • name: string

SKILL.md 中声明的技能名称。

minLength: 0

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

对象类型,固定为 inline。

  • "inline"

  • updated_at: integer

模板上次更新时的 Unix 时间戳,单位为秒。

format: int64

示例

## 从环境变量读取 API 密钥。
## 将 ENVIRONMENT_TEMPLATE_ID 设置为目标环境模板的 ID。
curl https://api.openai.com/v1/agents/environments/templates/$ENVIRONMENT_TEMPLATE_ID \
    -H 'OpenAI-Beta: agents=v1' \
    -H "Authorization: Bearer $OPENAI_API_KEY"

200 响应示例

字段名、类型值和示例标识均按接口定义保留。

{
  "id": "id",
  "capability_directories": [
    "string"
  ],
  "created_at": 0,
  "desktop": {
    "enabled": true
  },
  "files": [
    {
      "file_id": "file_id",
      "path": "path",
      "type": "file_id"
    }
  ],
  "name": "name",
  "network": {
    "access": "enabled",
    "allowed_domains": [
      "string"
    ]
  },
  "object": "agent.environment.template",
  "packages": {
    "npm": [
      "string"
    ],
    "python": [
      "string"
    ],
    "system": [
      "string"
    ]
  },
  "plugins": [
    {
      "description": "description",
      "name": "name",
      "type": "inline"
    }
  ],
  "skills": [
    {
      "skill_id": "skill_id",
      "type": "skill_reference",
      "version": "version"
    }
  ],
  "updated_at": 0
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号