Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.declaw.ai/llms.txt

Use this file to discover all available pages before exploring further.

import "github.com/declaw-ai/declaw-go"
A volume is a tenant-owned blob (gzip-compressed tar archive) that lives in Declaw’s object store. You upload a volume once with CreateVolume() and attach it to any number of sandboxes at create time via WithVolumes(). On boot, Declaw streams the blob from object storage and materializes its regular-file entries under the attachment’s MountPath before the first command runs.

declaw.CreateVolume()

Upload a tar.gz and register it.
data, err := os.ReadFile("dataset.tar.gz")
if err != nil {
    log.Fatal(err)
}
vol, err := declaw.CreateVolume(ctx, "training-set-v1", data)
if err != nil {
    log.Fatal(err)
}
fmt.Println(vol.VolumeID, vol.SizeBytes)
name
string
required
Human-readable name. The server returns a stable VolumeID.
data
[]byte
required
The gzip-compressed tar archive. Must start with gzip magic bytes (0x1F 0x8B). Pass nil or empty for an empty volume.
Returns (*VolumeInfo, error)

declaw.ListVolumes()

List all volumes owned by the caller.
volumes, err := declaw.ListVolumes(ctx)
for _, v := range volumes {
    fmt.Println(v.VolumeID, v.Name, v.SizeBytes)
}
Returns ([]VolumeInfo, error)

declaw.GetVolume()

Fetch metadata for a single volume.
vol, err := declaw.GetVolume(ctx, "vol-abc123")
Returns (*VolumeInfo, error)

declaw.DownloadVolume()

Download the contents of a volume as raw bytes.
data, err := declaw.DownloadVolume(ctx, "vol-abc123")
if err != nil {
    log.Fatal(err)
}
_ = os.WriteFile("backup.tar.gz", data, 0644)
Returns ([]byte, error)

declaw.DeleteVolume()

Delete a volume by its ID.
err := declaw.DeleteVolume(ctx, "vol-abc123")
Returns error

Attaching to a sandbox

Pass WithVolumes() to Create():
vol, _ := declaw.CreateVolume(ctx, "dataset", tarGzBytes)

sbx, err := declaw.Create(ctx,
    declaw.WithTemplate("python"),
    declaw.WithTimeout(600),
    declaw.WithVolumes([]declaw.VolumeAttachment{
        {VolumeID: vol.VolumeID, MountPath: "/data"},
    }),
)

// Files are already visible when the first command runs
result, _ := sbx.Commands.Run(ctx, "ls -la /data")
fmt.Println(result.Stdout)
The same VolumeID can appear in many sandbox-create calls in parallel; each sandbox gets its own materialized copy.

Data models

VolumeInfo

type VolumeInfo struct {
    VolumeID    string
    OwnerID     string
    Name        string
    BlobKey     string
    SizeBytes   int64
    ContentType string
    CreatedAt   string
    Metadata    map[string]string
}

VolumeAttachment

type VolumeAttachment struct {
    VolumeID  string
    MountPath string
}