Skip to main content

Installation

go get github.com/getnenai/nen-sdk-go
Zero external dependencies — uses only the Go standard library.

Quick Start

package main

import (
	"context"
	"fmt"

	nendesktop "github.com/getnenai/nen-sdk-go"
)

func main() {
	client := nendesktop.New(nendesktop.Config{APIKey: "sk_nen_..."})
	ctx := context.Background()

	// Create a desktop
	desktop, err := client.CreateDesktop(ctx, "sandbox")
	if err != nil {
		panic(err)
	}
	fmt.Printf("Created: %s (status: %s)\n", desktop.DesktopID, desktop.Status)

	// Take a screenshot
	result, err := client.Execute(ctx, desktop.DesktopID, "computer", "screenshot", nil)
	if err != nil {
		panic(err)
	}
	// result.Base64Image is a PNG, base64-encoded
	_ = result

	// List available tools
	tools, _ := client.ListTools(ctx, desktop.DesktopID)
	_ = tools

	// Clean up
	client.DeleteDesktop(ctx, desktop.DesktopID)
}

Configuration

client := nendesktop.New(nendesktop.Config{
	APIKey:  "sk_nen_...",
	BaseURL: "https://desktop.api.getnen.ai", // default
	Timeout: 30 * time.Second,                // default
})
The Execute method always uses a 120-second timeout, regardless of the client timeout.

Method Reference

Desktop CRUD

MethodReturnsDescription
CreateDesktop(ctx, desktopType)(*Desktop, error)Create a new desktop
ListDesktops(ctx)([]Desktop, error)List all active desktops
GetDesktop(ctx, desktopID)(*Desktop, error)Get a single desktop by ID
UpdateDesktop(ctx, desktopID, name)(*Desktop, error)Rename a desktop
DeleteDesktop(ctx, desktopID)(*DeleteResponse, error)Delete a desktop

Tool Execution

MethodReturnsDescription
Execute(ctx, desktopID, tool, action, params)(*ExecuteResult, error)Execute a tool action
ListTools(ctx, desktopID)([]ToolSchema, error)List available tools as JSON Schema
GetToolLogs(ctx, desktopID)(json.RawMessage, error)Get tool execution logs

Sessions

MethodReturnsDescription
CreateSession(ctx, desktopID)(*SessionInfo, error)Create or reconnect an RDP session
GetSession(ctx, desktopID)(*SessionInfo, error)Get current session status
DeleteSession(ctx, desktopID)errorDisconnect the session

Error Handling

All API errors return *APIError, which carries StatusCode and Body:
import "errors"

desktop, err := client.GetDesktop(ctx, "dsk_nonexistent")
if err != nil {
	var apiErr *nendesktop.APIError
	if errors.As(err, &apiErr) {
		fmt.Printf("Error %d: %s\n", apiErr.StatusCode, apiErr.Body)
	}
}
Inspect apiErr.StatusCode to differentiate (401, 404, 409, 5xx).