Get started

Quickstart

Get an API key, install LatentCode, run your first coding task, then run a hosted agent from your own code. It takes a few minutes.

Before you begin

  • A macOS, Linux or Windows machine where you can run a terminal. You don't need administrator rights.
  • The address of your LatentStack server. These docs are served from it: https://latentstack.dev.

1. Get your API key

Everything in LatentStack authenticates with a personal API key that starts with ls-. You get one automatically when your account is created.

  1. 1
    Sign in to the console

    Open https://latentstack.dev/login and sign in with your email and password. If your administrator created your account, the welcome email has a temporary password. If you don't have an account yet, choose Sign up on the sign-in page, or accept the invitation your administrator sent you.

  2. 2
    Copy your key

    Open the account menu at the top right and choose Account settings. In the API Key card, select Copy. If the card shows Generate API key instead, select it first.

  3. 3
    Keep it in your shell for this session
    $export LS_API_KEY="ls-…"
Treat the key like a password
Anyone with your key can use models on your account, and the usage is charged to you. If it leaks, select Regenerate on the same card. The old key stops working immediately.

2. Install

One command installs the LatentCode CLI, the LatentWork desktop app and the editor extension:

curl -fsSL https://latentstack.dev/install.sh | bash

The installer downloads everything from your server and points LatentCode at it. When it prints Done., open a new terminal so the latentcode command is on your PATH. To install only the CLI, or for other options, see Install.

3. Connect LatentCode

$latentcode config set api-key $LS_API_KEY
✓ API key saved → /home/you/.config/latentcode/latentcode.jsonc
✓ Imported 6 model(s) (tier: <your tier>)

LatentCode checks the key against the gateway and imports the models your tier allows. If you skip this step, LatentCode asks for the key the first time it starts.

4. Run your first task

Go to a project folder and start LatentCode:

Bash
cd ~/code/my-project
latentcode

The terminal UI opens. Type a request at the prompt and press Enter, for example:

Explain what this project does and how it is organized.

LatentCode reads the files it needs and answers in the conversation. It can edit files in the project directly, and it asks before running most shell commands. You can also run one request without the UI and print the answer:

$latentcode run "List the main entry points of this project"

latentcode run can't stop to ask you anything, so it declines any action that would need your permission, such as most shell commands, and prints a line saying so.

Next, see LatentCode for the TUI, the CLI and configuration.

5. Run an agent from your own code

The same key runs LatentCode agents in hosted sandboxes through the Agents API. Install the TypeScript or Python SDK, give an agent a task, and read what it did:

Give a hosted agent a task
import { LatentStack } from "@latentcode/sandbox-agents"

const client = new LatentStack({ apiKey: process.env.LS_API_KEY! })
const sessions = client.agents.sessions

const session = await sessions.create({
  agent: {
    model: "bedrock/us.anthropic.claude-sonnet-5",
    instructions: "Answer briefly.",
    // An empty sandbox has nothing to protect, so let the agent run commands without asking.
    permissions: [{ action: "bash", effect: "allow" }],
  },
  input: "Write a Python script that prints the first 10 prime numbers, run it, and show me the output.",
})

for await (const event of sessions.events(session.id)) {
  if (event.type === "tool.called") console.log("tool:", event.data?.tool)
  if (event.type === "text.ended") console.log(event.data?.text)
  if (event.type === "run.completed" || event.type === "run.failed") break
}

const { last_seq } = await sessions.get(session.id)
await sessions.message(session.id, "Now make it print the first 20.")

for await (const event of sessions.events(session.id, { after: last_seq })) {
  if (event.type === "text.ended") console.log(event.data?.text)
  if (event.type === "run.completed" || event.type === "run.failed") break
}

await sessions.delete(session.id)

The Agents API quickstart covers installing the SDK and running this end to end. Model calls made by agents show on your My Usage page like any other request.

Next steps