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

EnvironmentInfo beta().agents().environments().create(params, requestOptions = RequestOptions.none())
POST
/agents/environments

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

Parameters
EnvironmentCreateParams params
Optional<String> idempotencyKey
minLength1
maxLength256
Environment environment

The required hosting type and its configuration.

Optional<List<String>> vaultIds

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

minItems0
maxItems10
Returns
class EnvironmentInfo:

Safe metadata for a first-class execution environment.

String id

The ID of the environment.

minLength0

Files installed in the environment, without their contents.

minItems0
maxItems2000
JsonValue; object_
constant
constant

The object type. Always agent.environment.

List<HostedPlugin> plugins

Plugins installed in the environment, without their archive contents.

minItems0
maxItems2000
List<HostedSkill> skills

Skills installed in the environment, without their archive contents.

minItems0
maxItems2000
Status status

The current environment connection status.

Type type

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

Create an agent environment

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.agents.environments.EnvironmentCreateParams;
import com.openai.models.beta.agents.environments.EnvironmentInfo;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        EnvironmentCreateParams params = EnvironmentCreateParams.builder()
            .environment(EnvironmentCreateParams.Environment.builder().build())
            .build();
        EnvironmentInfo environmentInfo = client.beta().agents().environments().create(params);
    }
}
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"
}