Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

Create an agent environment

client.Beta.Agents.Environments.New(ctx, params) (*EnvironmentInfo, error)
POST
/agents/environments

Creates an OpenAI-hosted environment before creating a session. Requires access to the prewarming beta.

Parameters
params BetaAgentEnvironmentNewParams

Body param: The required hosting type and its configuration.

VaultIDs param.Field[[]string]
Optional

Body param: The IDs of up to 10 vaults made available to an OpenAI-hosted environment.

minItems0
maxItems10
IdempotencyKey param.Field[string]
Optional

Header param: Deduplicates creation for 24 hours within the authenticated organization, project, and creator. Retry the same JSON parameters with the same key to retrieve the original environment in its current state. Different parameters or an incomplete hosted creation return 409. Deleted environments are not recreated. After retention expires, the key may create a new environment. Without this header, each request creates a new environment.

minLength1
maxLength256
Returns
type EnvironmentInfo struct{…}

Safe metadata for a first-class execution environment.

ID string

The ID of the environment.

minLength0

Files installed in the environment, without their contents.

minItems0
maxItems2000
Object AgentEnvironment

The object type. Always agent.environment.

Plugins []HostedPlugin

Plugins installed in the environment, without their archive contents.

minItems0
maxItems2000

Skills installed in the environment, without their archive contents.

minItems0
maxItems2000
Status EnvironmentInfoStatus

The current environment connection status.

Type EnvironmentInfoType

Whether the environment is hosted by OpenAI or by the application.

Create an agent environment

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  environmentInfo, err := client.Beta.Agents.Environments.New(context.TODO(), openai.BetaAgentEnvironmentNewParams{
    Environment: openai.BetaAgentEnvironmentNewParamsEnvironment{

    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", environmentInfo.ID)
}
201 — Example
{
  "id": "id",
  "files": [
    {
      "id": "id",
      "file_id": "file_id",
      "path": "path",
      "size_bytes": 0,
      "type": "file_id"
    }
  ],
  "object": "agent.environment",
  "plugins": [
    {
      "description": "description",
      "name": "name",
      "type": "inline"
    }
  ],
  "skills": [
    {
      "description": "description",
      "name": "name",
      "skill_id": "skill_id",
      "type": "skill_reference",
      "version": "version"
    }
  ],
  "status": "pending",
  "type": "openai_hosted"
}
Returns Examples
201 — Example
{
  "id": "id",
  "files": [
    {
      "id": "id",
      "file_id": "file_id",
      "path": "path",
      "size_bytes": 0,
      "type": "file_id"
    }
  ],
  "object": "agent.environment",
  "plugins": [
    {
      "description": "description",
      "name": "name",
      "type": "inline"
    }
  ],
  "skills": [
    {
      "description": "description",
      "name": "name",
      "skill_id": "skill_id",
      "type": "skill_reference",
      "version": "version"
    }
  ],
  "status": "pending",
  "type": "openai_hosted"
}