Docs Start
Quickstart: TypeScript
Record one OpenAI call from a Node.js script as a Runback run, then open it in the app. About five minutes.
Before you begin
- A Runback account. Create one free.
- Node.js 20 or later. Check with
node --version. - An OpenAI API key, set as
OPENAI_API_KEY. No OpenAI key? Step 4 has a test command that needs none.
Steps
Get a Runback key
A key tells Runback which workspace a run belongs to. Use a Send only key: it can send runs and nothing else.In the app, open Settings › Keys and access › API key, keep Send only selected, select Generate API key and copy it. It is shown once, and starts
rb_cloud_. Creating keys needs a workspace admin; whoever created the workspace is one.Checking your session…
Install the SDK
In your project folder (or a new one), install Runback's SDK and the OpenAI client it wraps.
terminalShell npm install @runback/sdk openaiExpected outputnpm finishes with a line such as
added 2 packagesand no errors.Put your key in your shell
Runback's SDKs and the test script read the key from the
RUNBACK_API_KEYenvironment variable. Replace the placeholder with the key from step 1. If you signed in, step 1 has already filled it in.terminalShell export RUNBACK_API_KEY="<RUNBACK_API_KEY>"Expected outputNothing is printed. To check it is set, run
echo $RUNBACK_API_KEY; it should print your key, startingrb_cloud_.Record a model call
Save this as
agent.mjsand run it withOPENAI_API_KEYset. It makes one OpenAI call through the wrapped client, so the call is recorded as a run namedquickstart-agent.agent.mjsJavaScript // agent.mjs: run with OPENAI_API_KEY=sk-... node agent.mjs import OpenAI from "openai"; import { startRun } from "@runback/sdk/core"; import { wrapOpenAI } from "@runback/sdk/openai"; const task = "Say hello in three words."; const run = startRun({ runName: "quickstart-agent", input: task }); const openai = wrapOpenAI(new OpenAI(), run); const res = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: task }], }); const answer = res.choices[0].message.content; await run.finish({ output: answer, status: "success" }); console.log(answer);terminalShell OPENAI_API_KEY=sk-... node agent.mjsExpected outputThe model's short reply, for example
Hello there, friend.and nothing else. A line starting[runback]means the run was not sent: see Troubleshooting below.No OpenAI key? Skip this step and send a test run instead. It uses the
RUNBACK_API_KEYyou exported and installs nothing.terminalShell curl -fsSL https://runback.dev/api/quickstart | bashCheck the run arrived
Open Runs in the app. Your run is at the top, named
quickstart-agent. Open it to step through what the agent did.
Troubleshooting
| You see | What it means | Fix |
|---|---|---|
[runback] no RUNBACK_API_KEY set — dropped 3 events | The key is not set in the terminal you ran the agent from. | Run step 3 again in the same terminal (a new terminal tab starts without it), then run the agent again. |
[runback] ingest failed 401 {"error":"Invalid API key"} | Runback rejected the key: mistyped, revoked or expired. | Copy the whole key again, or create a new one in Settings › Keys and access › API key. |
OpenAIError: Missing credentials | OPENAI_API_KEY is not set. | Run the agent as OPENAI_API_KEY=sk-... node agent.mjs, or use the test-run command under step 4. |
AuthenticationError: 401 Incorrect API key provided | OpenAI rejected your OpenAI key (not your Runback key). | Check the key at platform.openai.com. |
Failed to load the ES module (Node 22+) or SyntaxError: Cannot use import statement outside a module (Node 20) | The file is not treated as an ES module. | Name it agent.mjs (not .js), or add "type": "module" to package.json. |
| The agent printed its reply but the run is not in Runs | The key belongs to a different workspace, or you are looking at the shared demo. | Check the workspace name in the top right of the app is the one the key came from. |
Your agent never fails because of Runback: if recording fails, the model call still returns and Runback prints one [runback] line saying why.
What the wrapper records
wrapOpenAI records every chat.completions and responses call: messages, system prompt, tools, parameters, the response, tool calls, tokens and latency, streamed or not. Your model call itself is unchanged, and nothing is stopped unless you add a policy. Emails, card numbers and keys are redacted inside your process before anything is sent; pass redact: false to startRun to turn that off.
Next steps
- Using the Vercel AI SDK, Anthropic or LangGraph? See Integrations.
- See what the run you sent contains: Capture.
- Stop a risky tool call before it runs: Control.
- Self-hosting Runback? Keys that do not start
rb_cloud_send tohttp://localhost:3000unless you setRUNBACK_INGEST_URLto your server.