Files
List container files
client.Containers.Files.List(ctx, containerID, query) (*CursorPage[ContainerFileListResponse], error)
get /containers/{container_id}/files
List container files
Parameters
-
containerID string -
query ContainerFileListParams-
After param.Field[string]A cursor for use in pagination.
afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. -
Limit param.Field[int64]A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
Order param.Field[ContainerFileListParamsOrder]Sort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
const ContainerFileListParamsOrderAsc ContainerFileListParamsOrder = "asc" -
const ContainerFileListParamsOrderDesc ContainerFileListParamsOrder = "desc"
-
-
Returns
-
type ContainerFileListResponse struct{…}-
ID stringUnique identifier for the file.
-
Bytes int64Size of the file in bytes.
-
ContainerID stringThe container this file belongs to.
-
CreatedAt int64Unix timestamp (in seconds) when the file was created.
-
Object ContainerFileThe type of this object (
container.file).const ContainerFileContainerFile ContainerFile = "container.file"
-
Path stringPath of the file in the container.
-
Source stringSource of the file (e.g.,
user,assistant).
-
Example
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"),
)
page, err := client.Containers.Files.List(
context.TODO(),
"container_id",
openai.ContainerFileListParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
Response
{
"data": [
{
"id": "id",
"bytes": 0,
"container_id": "container_id",
"created_at": 0,
"object": "container.file",
"path": "path",
"source": "source"
}
],
"first_id": "first_id",
"has_more": true,
"last_id": "last_id",
"object": "list"
}
Create container file
client.Containers.Files.New(ctx, containerID, body) (*ContainerFileNewResponse, error)
post /containers/{container_id}/files
Create container file
Parameters
-
containerID string -
body ContainerFileNewParams-
File param.Field[Reader]The File object (not file name) to be uploaded.
-
FileID param.Field[string]Name of the file to create.
-
Returns
-
type ContainerFileNewResponse struct{…}-
ID stringUnique identifier for the file.
-
Bytes int64Size of the file in bytes.
-
ContainerID stringThe container this file belongs to.
-
CreatedAt int64Unix timestamp (in seconds) when the file was created.
-
Object ContainerFileThe type of this object (
container.file).const ContainerFileContainerFile ContainerFile = "container.file"
-
Path stringPath of the file in the container.
-
Source stringSource of the file (e.g.,
user,assistant).
-
Example
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)
}
Response
{
"id": "id",
"bytes": 0,
"container_id": "container_id",
"created_at": 0,
"object": "container.file",
"path": "path",
"source": "source"
}
Retrieve container file
client.Containers.Files.Get(ctx, containerID, fileID) (*ContainerFileGetResponse, error)
get /containers/{container_id}/files/{file_id}
Retrieve container file
Parameters
-
containerID string -
fileID string
Returns
-
type ContainerFileGetResponse struct{…}-
ID stringUnique identifier for the file.
-
Bytes int64Size of the file in bytes.
-
ContainerID stringThe container this file belongs to.
-
CreatedAt int64Unix timestamp (in seconds) when the file was created.
-
Object ContainerFileThe type of this object (
container.file).const ContainerFileContainerFile ContainerFile = "container.file"
-
Path stringPath of the file in the container.
-
Source stringSource of the file (e.g.,
user,assistant).
-
Example
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.Get(
context.TODO(),
"container_id",
"file_id",
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", file.ID)
}
Response
{
"id": "id",
"bytes": 0,
"container_id": "container_id",
"created_at": 0,
"object": "container.file",
"path": "path",
"source": "source"
}
Delete a container file
client.Containers.Files.Delete(ctx, containerID, fileID) error
delete /containers/{container_id}/files/{file_id}
Delete a container file
Parameters
-
containerID string -
fileID string
Example
package main
import (
"context"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Containers.Files.Delete(
context.TODO(),
"container_id",
"file_id",
)
if err != nil {
panic(err.Error())
}
}
Content
Retrieve container file content
client.Containers.Files.Content.Get(ctx, containerID, fileID) (*Response, error)
get /containers/{container_id}/files/{file_id}/content
Retrieve container file content
Parameters
-
containerID string -
fileID string
Returns
type ContainerFileContentGetResponse interface{…}
Example
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"),
)
content, err := client.Containers.Files.Content.Get(
context.TODO(),
"container_id",
"file_id",
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", content)
}