Quickstart

Get Threadline running in your project in under 5 minutes.

Installation

Install the SDK from npm.

npm install threadline-sdk

Authentication

Initialize Threadline with your API key from the dashboard.

import { Threadline } from "threadline-sdk"

const tl = new Threadline({
  apiKey: process.env.THREADLINE_KEY!
})

Context Objects

Context objects are the unit of memory Threadline stores per user — facts, preferences, and conversational history that persist across sessions.

Scopes & Grants

Scopes control which agents can read or write to a user's context. Grants are time-bound permissions you issue to specific agents or tools.

Inject & Update

Inject context before your LLM call, then update it after each exchange.

const { injectedPrompt } = await tl.inject(userId, basePrompt)

const response = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "system", content: injectedPrompt }],
})

await tl.update({ userId, userMessage, agentResponse })

That's it. Your agent now remembers every user, forever. For the full API reference and SDK options, browse the sidebar.