Skip to content

Create container file

client.Containers.Files.New(ctx, containerID, body) (*ContainerFileNewResponse, error)
POST/containers/{container_id}/files

Create a Container File

You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.

ParametersExpand Collapse
containerID string
body ContainerFileNewParams
File param.Field[Reader]optional

The File object (not file name) to be uploaded.

FileID param.Field[string]optional

Name of the file to create.

ReturnsExpand Collapse
type ContainerFileNewResponse struct{…}
ID string

Unique identifier for the file.

Bytes int64

Size of the file in bytes.

ContainerID string

The container this file belongs to.

CreatedAt int64

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

Object ContainerFile

The type of this object (container.file).

Path string

Path of the file in the container.

Source string

Source of the file (e.g., user, assistant).

Create container file

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"),
  )
  file, err := client.Containers.Files.New(
    context.TODO(),
    "container_id",
    openai.ContainerFileNewParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", file.ID)
}
{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "container.file",
  "path": "path",
  "source": "source"
}
Returns Examples
{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "container.file",
  "path": "path",
  "source": "source"
}