Skip to main content
Use the Dedalus Go SDK to create and manage persistent Linux machines from your application. Create one or many machines for a project, run commands, and reuse their files across sessions. Your application calls the SDK. Commands submitted through the SDK run inside the machine. You can also change machine resources, control sleep and wake, request SSH access, and inspect usage.

Install

Use Go 1.22 or later. Run this command inside a Go module:

Authenticate

Create an API key in the Dedalus Dashboard, then set it in the environment:
dedalus.NewClient() reads DEDALUS_API_KEY automatically.

Create a machine

This creates a machine with 1 vCPU, 4,096 MiB of memory, 10 GiB of storage, and autosleep after five idle minutes:
Use the saved machine.MachineID in later requests for this machine. Machine creation is asynchronous. The response contains the requested state and the machine’s current lifecycle status. You can submit an execution immediately after creation. Dedalus waits for the machine to start before running the command.

Run a command

An execution is one command run inside a machine. Creating an execution returns an ExecutionID before the command finishes. Use that ID to check the command’s status and retrieve its output. This function writes a file, reads it back, and waits for the execution to finish:
Example output when the function is called:
Execution status is separate from API status. A successful API request can return an execution whose status is failed. Check the execution status before using its output. TimeoutMs limits how long the command can run inside the machine. The execution continues independently of your application’s polling loop until it finishes, is cancelled, expires, or reaches that timeout. See Executions for working directories, environment variables, input, cancellation, and output limits.

Reuse the machine

Dedalus Machines are persistent. Save the machine ID to reuse the same filesystem across application sessions. In a later application session, retrieve the saved ID:
The returned machine contains the machine’s current state. Submit another execution with machine.MachineID to continue working. Executions wake a sleeping machine automatically. Sleep preserves files on the root filesystem and resets processes and memory. See persistence for the complete lifecycle contract. When you no longer need the machine or its files, explicitly request deletion:
Deletion removes the machine and its files. Sleep and autosleep preserve the machine for another session.

Watch lifecycle changes

WatchStreaming streams machine state changes using server-sent events (SSE). DesiredState is the requested state. Status.Phase is the machine’s current state. This function requests sleep and reads updates until the machine is sleeping:
Each update contains a complete machine response. defer stream.Close() closes the open stream when the function returns. The stream closes when the machine reaches its desired state, reports a terminal error, or the five-minute watch limit expires. The final retrieve confirms the machine’s current state.

List machines

Machine lists are paginated. Limit sets the number of machines requested in each page, and Cursor continues from a previous page. Use ListAutoPaging to fetch pages automatically:
To request one page at a time, inspect Items and call GetNextPage() only when you want another request. A nil page means there are no more pages.

Configure requests

Pass options to dedalus.NewClient(...) for every request, or after a method’s parameter struct for one request.

Retries and timeouts

The SDK retries connection failures, HTTP 408, 409, 429, and 5xx responses twice by default, with increasing delays between attempts. An explicit x-should-retry response header overrides the status-based decision. A context deadline limits the entire call, including retries. option.WithRequestTimeout limits each attempt separately. Neither adds a timeout unless you configure it.

SDK methods

The SDK groups related methods under services. Every method accepts a context and a parameter struct. Check its returned error before using the result. Use the API reference for every request field and response field.

Handle errors

An API request and a command can fail independently. A nil error from Executions.Get can accompany a failed command: check execution.Status, ExitCode, ErrorMessage, and captured Stderr before using its results. After an HTTP timeout, use the execution ID to retrieve the existing execution. Submitting another command creates another execution. Request deadlines control HTTP waiting, execution TimeoutMs controls command runtime, and machine Autosleep controls idle compute. Unsuccessful HTTP responses return *dedalus.Error. Use errors.As to inspect StatusCode and RawJSON():
In v0.4.0, error-body fields such as error_code, message, and retryable are not named Go struct fields. Decode RawJSON() into your own type when your application needs them.

Advanced client options

Work with request and response fields

Optional primitive request fields use param.Opt[T]. Constructors such as dedalus.String("5m") and dedalus.Int(20) set them. Use param.Null[T]() only when the API permits an explicit JSON null. Response structs expose values directly and keep JSON metadata in a JSON field. Check response.JSON.Field.Valid() before interpreting an optional field’s zero value. Use response.RawJSON() for the original response.

Inspect HTTP responses

Use option.WithResponseInto when you need the HTTP status or headers with the parsed result:

Logging

Pass option.WithDebugLog(nil) to use the default debug logger, or provide a log.Logger.

Customize HTTP requests

Use option.WithHTTPClient to supply an HTTP client with your proxy, transport, or connection settings. Use option.WithMiddleware to add application-specific timing or diagnostics around requests.

Requests beyond the generated types

client.Get, client.Post, and the other HTTP methods let you call endpoints that do not have service methods. Client options such as authentication and retries still apply. Use option.WithQuerySet for extra query parameters and option.WithJSONSet for body fields.

Multipart file uploads

For endpoints that accept multipart files, upload parameters use io.Reader. Wrap a reader with dedalus.File(reader, filename, contentType) to set the filename and content type.

Versioning

Review the release notes before upgrading. If you depend on an internal interface, or find a compatibility issue, report it in the SDK issue tracker.
Last modified on September 9, 2026