A lightweight service for managing threads and messages for AI SDK driven LLM applications.
- Start the server
npx ctx-store
- Initialize the client
import { createClient } from "@ctx-store/client";
const ctxStore = createClient();
- Create a thread and add a message
const thread = await ctxStore.createThread();
await ctxStore.createMessages(thread.id, [
{
role: "user",
content: "Hello, world!",
},
]);
- Use together with AI SDK
const { text } = await generateText({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello, world!" }],
onFinish: async ({ response }) => {
await ctxStore.createMessages(thread.id, response.messages);
},
});