How do I install the Suede AI SDK?#
Run one npm install. The package ships the SDK and the suede command, written in TypeScript with full type definitions, and it pulls in no model SDKs: Agent Studio provides the model.
npm install @suedeai/agents
npx suede init # writes agent.ts, package.json, .gitignore and .suede/config.json
npx suede login <key> # your workspace key from the Workspace pageFrom install to live endpoint
Step 1: Copy your workspace key
Open Workspace, click Reveal under This key is your workspace., then Copy.Open WorkspaceStep 2: Install and scaffold
Runnpm install @suedeai/agents, thennpx suede initin an empty folder.Step 3: Log in
Runnpx suede login {key}. The CLI verifies the key and saves it to.suede/config.json.Step 4: Run it locally
SetSUEDE_GATEWAY_STUB=1and runnpx suede dev, then POST tolocalhost:3001/run.Step 5: Push it live
RunSee it in Workspacenpx suede push. The CLI prints your slug and live URL, and the agent appears in Workspace.
What does an agent look like in code?#
An agent is a name, a list of triggers and an async run function. defineAgent validates the definition and freezes it, so a bad cron string or an empty trigger list fails on your machine instead of in production.
import { defineAgent, schedule, manual, suede } from "@suedeai/agents";
export default defineAgent({
name: "price-watcher",
description: "Reads a product page excerpt, remembers the price, flags a drop.",
triggers: [schedule("0 13 * * *"), manual()],
async run({ input, memory }) {
const out = await suede.llm({
system: "Extract the price as a number.",
prompt: String(input ?? ""),
});
const last = await memory.get<number>("lastPrice");
await memory.set("lastPrice", Number(out.text));
return { price: out.text, dropped: last !== undefined && Number(out.text) < last };
},
});suede.llm({ system, prompt })calls the Agent Studio model gateway and returns{ text }, billed to your usage credit.suede.run(nodeType, config)calls any Agent Studio node from code and returns{ output }.memory.getandmemory.setkeep state between runs; locally they write to.suede/memory.json.- A gateway failure throws a typed
GatewayErrorwhosestatusis401(bad key),402(out of credit) or429(rate limited).
Which triggers can start a code agent?#
Four trigger helpers cover every way work arrives. Combine them freely: one agent can run on a schedule and on demand.
| Helper | Starts a run when | Notes |
|---|---|---|
schedule(cron) | The cron time arrives | Five-field cron in UTC, validated at define time |
manual() | You or your code calls it | Run from Workspace or the run endpoint |
webhook() | A signed request reaches the agent | Pairs with signed webhooks and the relay |
paidCall(price) | A buyer pays per call | Optional; see Sell your agent per call |
Which CLI commands does Agent Studio support?#
| Command | What it does |
|---|---|
suede init | Scaffolds agent.ts, package.json, .gitignore and .suede/config.json |
suede login {key} | Verifies and saves your workspace key |
suede push | Publishes agent.ts and prints the slug and live URL |
suede pull {slug} | Writes manifest.json and agent.ts from a published agent |
suede dev | Serves the agent on port 3001: POST /run and GET /manifest |
suede versions list {flowId} | Lists immutable published versions |
suede versions pull {flowId} {id} | Pulls one version to your machine |
suede versions inspect {flowId} {id} | Shows a version's hashes and pins |
suede versions export {flowId} {id} | Exports a self-hostable bundle of that version |
suede link {slug} --url {url} | Routes calls for a published agent to your own server |
suede whoami | Prints the API URL and your key prefix |
How do I develop and self-host an agent?#
Set SUEDE_GATEWAY_STUB=1 and suede.llm echoes your prompt with no network call and no key, so you iterate offline at zero cost. When you want your own box to do the work, serve(agent, { port }) starts a plain Node HTTP server with the same POST /run and GET /manifest routes.
SUEDE_GATEWAY_STUB=1 npx suede dev
curl -X POST http://localhost:3001/run \
-H 'content-type: application/json' \
-d '{ "input": "Widget Pro, now $89" }'Keep the Agent Studio endpoint your callers already use while your own server runs the code. suede link prints a relay secret once; start your server with it so it accepts calls forwarded by Agent Studio.
npx suede link <slug> --url https://your-server.com/run
# prints SUEDE_RELAY_SECRET=<hex> (save it now)
SUEDE_RELAY_SECRET=<hex> node dist/agent.jsWhich environment variables does the SDK read?#
| Variable | Purpose |
|---|---|
SUEDE_WORKSPACE_KEY | Authenticates live gateway calls |
SUEDE_GATEWAY_STUB=1 | Offline echo mode: no HTTP, no key |
SUEDE_API_URL | Overrides the platform URL (default https://agents.suedeai.ai) |
SUEDE_RELAY_SECRET | Authenticates relay-forwarded calls inside serve() |
Prefer a canvas?
Every template opens on the visual builder too, with free dry runs on every step.