Skip to main content
Use the Compute API client to create Linux, macOS, or Windows instances from a Node.js application. Create a client and provision your first instance.

Create your first instance

The following example creates a Linux instance with 2 vCPUs and 4 GiB of memory, prints its instance ID, and waits for it to start.
1

Authenticate with Namespace

For local development, authenticate with the Namespace CLI:
The SDK uses a Namespace workload token when available and otherwise the local user token created by nsc login.
2

Create a Compute client

Import createComputeClient() and create a client:
The client loads credentials on its first authenticated request and uses the us regional endpoint by default.
3

Create an instance

Create a Linux instance with a 30-minute deadline:
The deadline releases the instance after 30 minutes.
4

Print the instance ID

Read the instance ID from the response metadata:
5

Wait for the instance

Instance creation is asynchronous. Wait until the instance reaches the RUNNING state:
See Create and manage compute instances for request fields, platform examples, placement, readiness handling, and the rest of the instance lifecycle.

Explore Compute

Create and manage instances

Create, wait for, inspect, list, extend, suspend, wake, and destroy instances.

Compute Client

Configure authentication, region, and transport, and see every compute service.

Authenticate with Namespace

Configure credentials for local development and automated workloads.

Access and networking

Expose ingresses and read SSH, VNC, and Kubernetes configuration.

Run commands

Run a command in a container and stream or buffer its output.

Inspect and release volumes

List, describe, and destroy cache and persistent volumes.

Report on usage

Compute, volume, and artifact usage, time series, and reports.

Read logs and egress

Stream and fetch instance logs and egress records.

Compute platform

Learn about platforms, machine shapes, storage, and instance access.
Last modified on September 25, 2026