Quick start
In this guide you create an API key, find a machine, start a container on it, connect over SSH and stop it. Each step is shown four ways: the CLI, curl, Go and JavaScript. Follow the one you prefer.
You need an OctaSpace account with a positive balance: a running session is charged to it.
1. Create an API key
- Sign in to the OctaSpace dashboard.
- In the sidebar, open Account → Credentials.
- In the API Keys section, click New key.
- Enter a Label that tells you where the key is used, for example quickstart, and click Create key.
- Copy the key. It starts with octa_ak_.
Export it in your shell, so the examples below can use it without the key appearing in your code or shell history:
read -rs OCTA_API_KEY && export OCTA_API_KEY(Paste the key and press Enter; nothing is shown while you type.)
2. Install a tool
CLI. Download the binary for your platform from the release page, put it on your PATH and log in:
octa --version
octa auth "$OCTA_API_KEY"octa auth checks the key and saves it to ~/.config/octa/config.yaml (readable only by you).
curl. Nothing to install. The examples also use jq to read JSON.
Go (1.20 or later):
go get github.com/octaspace/go-sdkJavaScript / TypeScript (Node.js 22 or later, Deno, Bun or a browser):
npm install @octaspace/sdk3. Check your balance
CLI
octa accountcurl
curl -s https://api.octa.space/accounts/balance \
-H "Authorization: Bearer $OCTA_API_KEY"The balance is in micro-USD: 12500000 is $12.50.
Go
client := octaspace.NewClient(os.Getenv("OCTA_API_KEY"))
balance, err := client.Accounts.Balance(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println("Balance:", balance.Balance) // Balance: $12.500000JavaScript
import { OctaClient, formatUsd } from '@octaspace/sdk'
const client = new OctaClient({ apiKey: process.env.OCTA_API_KEY })
const { balance } = await client.accounts.balance()
console.log('Balance:', formatUsd(balance)) // Balance: $12.500000If you get 401 Invalid bearer token, the key is wrong or was deleted.
4. Find a machine
Every machine has a node number such as 7KQ4-M2XD-4. Pick one from the listing and note its number.
CLI
octa compute
octa compute search "rtx 4090"search matches the CPU and GPU model, country and city.
curl
curl -s https://api.octa.space/services/compute \
-H "Authorization: Bearer $OCTA_API_KEY" \
| jq -r '.[] | [.node_number, .city, .base_price] | @tsv'base_price is the price per hour in micro-USD.
Go
machines, err := client.Compute.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, m := range machines {
fmt.Println(m.NodeNumber, m.City, m.BasePrice, "per hour")
}JavaScript
const machines = await client.compute.list()
for (const m of machines) {
console.log(m.node_number, m.city, formatUsd(m.base_price), 'per hour')
}5. Start a session
Start an ubuntu:24.04 container with SSH access. Replace 7KQ4-M2XD-4 with the node number you picked.
CLI
octa compute start --node 7KQ4-M2XD-4 --image ubuntu:24.04 --ssh --wait--wait follows the progress (image pull, setup) and, when the session is ready, prints how to reach it.
curl
curl -s https://api.octa.space/services/compute \
-H "Authorization: Bearer $OCTA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"node_number": "7KQ4-M2XD-4", "image": "ubuntu:24.04", "ssh": true}'The response is 201 with the session UUID:
{ "uuid": "96e33710-ec12-11ed-8588-fa163e49e8aa" }Poll the session until its status changes from starting to ready (every few seconds is enough):
UUID=96e33710-ec12-11ed-8588-fa163e49e8aa
curl -s https://api.octa.space/services/$UUID/info \
-H "Authorization: Bearer $OCTA_API_KEY" \
| jq '{status, progress, pull_percent}'Go
uuid, err := client.Compute.Start(ctx, &octaspace.ComputeStartParams{
NodeNumber: "7KQ4-M2XD-4",
Image: "ubuntu:24.04",
SSH: octaspace.Bool(true),
})
if err != nil {
log.Fatal(err)
}
waitCtx, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()
session, err := client.Sessions.WaitReady(waitCtx, uuid, nil)
if err != nil {
log.Fatal(err)
}JavaScript
const { uuid } = await client.compute.start({
node_number: '7KQ4-M2XD-4',
image: 'ubuntu:24.04',
ssh: true,
})
const session = await client.sessions.waitReady(uuid, {
timeoutMs: 10 * 60_000,
onProgress: (s) => console.log(s.status, s.progress, s.pull_percent),
})Starting usually takes from a few seconds to a few minutes, depending on the image size. If the session stops while starting (for example, SSH could not be set up), the SDKs raise a "session stopped" error and the CLI reports it.
6. Connect
When the session is ready, its info contains the SSH endpoints: ssh.direct (straight to the node) and ssh.proxy (through the OctaSpace proxy), each with host, port and user, plus ssh.web, a web terminal URL.
CLI
octa compute connect 96e3The CLI accepts a unique prefix of the session UUID.
curl
curl -s https://api.octa.space/services/$UUID/info \
-H "Authorization: Bearer $OCTA_API_KEY" \
| jq '.ssh'Then connect with the values you got:
ssh -p <port> <user>@<host>Go
if d := session.SSH.Direct; d != nil {
fmt.Printf("ssh -p %d %s@%s\n", d.Port, d.User, d.Host)
}JavaScript
const d = session.ssh?.direct
if (d) console.log(`ssh -p ${d.port} ${d.user}@${d.host}`)7. Stop the session
A session is charged until you stop it. Stopping twice is safe.
CLI
octa sessions # your running sessions
octa sessions stop 96e3curl
curl -s -X POST https://api.octa.space/services/$UUID/stop \
-H "Authorization: Bearer $OCTA_API_KEY"Go
if _, err := client.Sessions.Stop(ctx, uuid); err != nil {
log.Fatal(err)
}JavaScript
await client.sessions.stop(uuid)After a few seconds the session disappears from GET /sessions, and its info returns 404.
If something goes wrong
Errors come with an HTTP status and a message, for example {"message": "Insufficient balance"}.
Status | What it means | What to do |
|---|---|---|
400, 422 | A parameter is missing or invalid (wrong node number, unknown field) | Read the message and fix the request |
401 | The API key is missing, wrong or deleted | Check OCTA_API_KEY, create a new key if needed |
404 | The session has stopped or the UUID is unknown; the node is not available | List your sessions or pick another machine |
409 | The session is still starting or restarting | Wait and try again |
429 | Too many requests | Wait the number of seconds in Retry-After |
5xx | A temporary problem on our side | Retry later. Before you retry a start, check GET /sessions: the session may have started |
When you contact support about a failed call, include the request ID: the SDKs expose it on the error object.
Next steps
- Expose ports and HTTP services, set environment variables, run a startup script: see the POST /services/compute parameters in the API reference or octa compute start --help.
- Start many sessions at once with batch start (client.Compute.StartBatch in Go, client.compute.startBatch in JavaScript).
- Hosting nodes? Manage their prices and maintenance with octa hosting or the client.hosting resource.
- Use the CLI in scripts: every command has -o json.