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

Create container

client.Containers.New(ctx, body) (*ContainerNewResponse, error)
POST/containers

Create Container

ParametersExpand Collapse
body ContainerNewParams
Name param.Field[string]

Name of the container to create.

ExpiresAfter param.Field[ContainerNewParamsExpiresAfter]Optional

Container expiration time in seconds relative to the ‘anchor’ time.

FileIDs param.Field[[]string]Optional

IDs of files to copy to the container.

MemoryLimit param.Field[ContainerNewParamsMemoryLimit]Optional

Optional memory limit for the container. Defaults to “1g”.

NetworkPolicy param.Field[ContainerNewParamsNetworkPolicyUnion]Optional

Network access policy for the container.

Skills param.Field[[]ContainerNewParamsSkillUnion]Optional

An optional list of skills referenced by id or inline data.

ReturnsExpand Collapse
type ContainerNewResponse struct{…}
ID string

Unique identifier for the container.

CreatedAt int64

Unix timestamp (in seconds) when the container was created.

formatunixtime
Name string

Name of the container.

Object string

The type of this object.

Status string

Status of the container (e.g., active, deleted).

ExpiresAfter ContainerNewResponseExpiresAfterOptional

The container will expire after this time period. The anchor is the reference point for the expiration. The minutes is the number of minutes after the anchor before the container expires.

LastActiveAt int64Optional

Unix timestamp (in seconds) when the container was last active.

formatunixtime
MemoryLimit ContainerNewResponseMemoryLimitOptional

The memory limit configured for the container.

NetworkPolicy ContainerNewResponseNetworkPolicyOptional

Network access policy for the container.

Create container

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"),
  )
  container, err := client.Containers.New(context.TODO(), openai.ContainerNewParams{
    Name: "name",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", container.ID)
}
{
    "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": "My Container"
}
Returns Examples
{
    "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": "My Container"
}