Examples

TypeScript + OpenAI / Anthropic

Add persistent memory to a TypeScript or Node.js agent in two lines.

1. Install

npm install @coorda/sdk openai
# or
npm install @coorda/sdk @anthropic-ai/sdk

2. Wrap the OpenAI client

import { Coorda } from "@coorda/sdk";
import OpenAI from "openai";

const coorda = new Coorda({ apiKey: "ck_live_..." });
const openai = coorda.wrap(new OpenAI(), { agentId: "triage-bot" });

const response = await openai.chat.completions.create(
  {
    model: "gpt-4o",
    messages: [{ role: "user", content: "Customer asking about billing" }],
  },
  { coorda: { entityId: "customer_123" } }
);

Or wrap the Anthropic client

import { Coorda } from "@coorda/sdk";
import Anthropic from "@anthropic-ai/sdk";

const coorda = new Coorda({ apiKey: "ck_live_..." });
const claude = coorda.wrap(new Anthropic(), { agentId: "triage-bot" });

await claude.messages.create(
  {
    model: "claude-sonnet-4-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Summarize this ticket" }],
  },
  { coorda: { entityId: "customer_123" } }
);
What happens on every call
Before the call, Coorda searches for prior context tagged to the entityId and prepends it (system message for OpenAI, user prefix for Anthropic). After the call returns, the input/output pair is stored asynchronously.

Per-call options

await openai.chat.completions.create(params, {
  coorda: {
    entityId: "customer_123",
    skipInject: true,      // don't pull prior context for this call
    skipStore: true,       // don't save the output
    minSimilarity: 0.5,
    limit: 3,
    metadata: { priority: "high" },
  },
});

// Pass { coorda: false } to fully bypass Coorda for this call.
await openai.chat.completions.create(params, { coorda: false });
Use with any framework
If you use LangChain or the Vercel AI SDK, they run OpenAI or Anthropic under the hood. Wrap the underlying client the same way and every downstream call inherits the memory automatically.