Containers
Create a container
Creates a container from the supplied request.
Anforderungstext
The request body.
name
string
Erforderlich
Name of the container to create.
file_ids
string[]
IDs of files to copy to the container.
expires_after
OpenAI.CreateContainerBodyExpiresAfter
anchor
enum
Erforderlich
skills
OpenAI.ContainerSkill[]
An optional list of skills referenced by id or inline data.
memory_limit
enum
Optional memory limit for the container. Defaults to "1g".
network_policy
disabled | allowlist
Network access policy for the container.
disabled
OpenAI.ContainerNetworkPolicyDisabledParam
type
enum
Erforderlich
Disable outbound network access. Always disabled.
allowlist
OpenAI.ContainerNetworkPolicyAllowlistParam
type
enum
Erforderlich
Allow outbound network access only to specified domains. Always allowlist.
allowed_domains
string[]
Erforderlich
A list of allowed domains when type is allowlist.
Antworten
The request has succeeded.
Text
id
string
Erforderlich
Unique identifier for the container.
object
string
Erforderlich
The type of this object.
name
string
Erforderlich
Name of the container.
created_at
integer
Erforderlich
Unix timestamp (in seconds) when the container was created.
status
string
Erforderlich
Status of the container (e.g., active, deleted).
last_active_at
integer
Unix timestamp (in seconds) when the container was last active.
expires_after
OpenAI.ContainerResourceExpiresAfter
anchor
enum
memory_limit
enum
The memory limit configured for the container.
network_policy
disabled | allowlist
Network access policy for the container.
disabled
OpenAI.ContainerNetworkPolicyDisabledParam
type
enum
Erforderlich
Disable outbound network access. Always disabled.
allowlist
OpenAI.ContainerNetworkPolicyAllowlistParam
type
enum
Erforderlich
Allow outbound network access only to specified domains. Always allowlist.
allowed_domains
string[]
Erforderlich
A list of allowed domains when type is allowlist.
Anfordern
curl https://api.openai.com/v1/containers \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Container",
"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"]
}
}'
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
const container = await client.containers.create({ name: 'name' });
console.log(container.id);
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
container = client.containers.create(
name="name",
)
print(container.id)
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
", container.ID)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.containers.ContainerCreateParams;
import com.openai.models.containers.ContainerCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ContainerCreateParams params = ContainerCreateParams.builder()
.name("name")
.build();
ContainerCreateResponse container = client.containers().create(params);
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
container = openai.containers.create(name: "name")
puts(container)
Antwort
{
"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"
}