cortyxia
v0.1.13
Published
The Memory Layer for Enterprise AI — one API swap adds persistent memory and 40% token cost reduction to any LLM stack
Maintainers
Readme
Cortyxia TypeScript SDK
Your LLM app with a memory upgrade. Drop-in persistent memory. 40% fewer tokens. One line to get started.
Why Cortyxia?
Building LLM apps that "remember" across sessions shouldn't require a PhD in vector databases, embedding pipelines, or context-window math.
Cortyxia is a drop-in memory layer — you swap your openai.chat.completions.create() for client.chat.completions.create(), and suddenly your app remembers everything. No schema design. No Pinecone setup. No chunking strategies. It just works.
Under the hood: a memory node infrastructure with multi-tier graph mechanisms (raw → indexed → entity-linked) and separate node architecture per tier. ONNX extractors, cross-encoder reranking, and semantic relevance scoring run at the proxy layer — sub-50ms routing overhead, zero prompt changes, fully compatible with whatever RAG or vector DB you're already running.
What you get
- Persistent memory — conversations, facts, and context survive restarts
- 40% token cost reduction — intelligent context assembly sends only what matters
- Multi-provider routing — Groq, OpenAI, Anthropic, Gemini, DeepSeek, xAI via one ISO token
- Project isolation — separate memory namespaces per team/project
- Dev mode keys — isolated context windows for agentic coding workflows
What you DON'T need
- No vector DB setup (Pinecone, Weaviate, Chroma, etc.)
- No embedding pipeline
- No chunking / token-counting logic
- No config files to manage
- No signup forms — just an email
The 30-Second Test
npm install cortyxiaSet your provider key, provider, and model in a .env file, then:
import { Cortyxia } from "cortyxia";
const client = await Cortyxia.create();
const key = await client.initialize(); // Creates project + key from your .env
// Chat with memory
const resp = await client.chat.completions.create({
messages: [{ role: "user", content: "My name is Alice" }],
});
// Later, in a new session:
const resp2 = await client.chat.completions.create({
messages: [{ role: "user", content: "What's my name?" }],
});
// It remembers. It answers "Alice".No database connection strings. No index creation. One package. One line. Done.
Installation
npm install cortyxia
# or
yarn add cortyxia
# or
pnpm add cortyxia- Node.js >= 18
- Zero runtime dependencies (uses native
fetch)
One-Shot Setup (Recommended)
Create a .env file in your project root:
# .env
[email protected]
API_KEY=gsk_your_groq_key_here
API_PROVIDER=groq
API_MODEL=llama-3.1-8b-instant
# Optional: DEV_MODE=trueThen one line:
import { Cortyxia } from "cortyxia";
const client = await Cortyxia.create();
const key = await client.initialize(); // Creates "Default Project" + "Default Key"
console.log(key.iso_token); // Grab your ISO token.env is parsed automatically — no dotenv package needed. We read it with fs (Node.js built-in).
Migrating from OpenAI / LangChain / Raw HTTP
Already using openai? Swap is two lines:
// Before
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk-..." });
const resp = await client.chat.completions.create({ model: "gpt-4o", messages: [...] });
// After
import { Cortyxia } from "cortyxia";
const client = await Cortyxia.create();
const resp = await client.chat.completions.create({ messages: [...] }); // model auto-resolvedYour prompts don't change. Your message format doesn't change. The response shape is identical. If you don't like it, remove the import and go back. No lock-in.
Chat
Non-streaming
import { Cortyxia, answer } from "cortyxia";
const client = await Cortyxia.create();
const resp = await client.chat.completions.create({
messages: [{ role: "user", content: "What was I working on yesterday?" }],
});
console.log(answer(resp)); // Just the assistant textStreaming
const stream = await client.chat.completions.stream({
messages: [{ role: "user", content: "Explain quantum computing" }],
});
// stream is a Response; consume with a reader or pipe to SSE parserUse a specific key (isoToken)
const resp = await client.chat.completions.create({
messages: [{ role: "user", content: "Hello" }],
isoToken: "iso-your-token-here", // Overrides default key
});Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| messages | ChatMessage[] | Yes | OpenAI-format messages |
| model | string | No | Model ID (auto-resolved from key if omitted) |
| isoToken | string | No | Specific key to use |
| temperature | number | No | Sampling temperature |
| maxTokens | number | No | Max output tokens |
Memory
Add a memory node
const node = await client.memory.add(
"User prefers Rust over Go for systems programming",
["preference", "language"]
);Query memory
const results = await client.memory.query("What language does the user prefer?", 5);
for (const hit of results.hits) {
console.log(hit.content);
}Query scoped to a specific key
const results = await client.memory.query("deployment issues", "iso-your-token");Projects
// List all projects
const projects = await client.projects.list();
// Create
const project = await client.projects.create("Agentic Coding", true);
// Get / Delete
const fetched = await client.projects.get(project.id);
await client.projects.delete(project.id);Keys
Create a key
const key = await client.keys.create(client.projectId!, {
label: "Production Key",
provider: "groq",
model: "llama-3.1-8b-instant",
groqKey: "gsk_your_key_here", // or use provider-mapped field
});Create with explicit provider fields
const key = await client.keys.create(client.projectId!, {
label: "OpenAI Key",
provider: "openai",
model: "gpt-4o",
openaiKey: "sk-...",
});Dev mode key (isolated context)
const key = await client.keys.create(client.projectId!, {
label: "Claude Agent",
provider: "anthropic",
model: "claude-sonnet-4-20250514",
devMode: true,
devNamespace: "agent_1",
recentWindowMin: 2,
recentWindowMax: 8,
});Update
// By key ID
await client.keys.update(client.projectId!, key.id, {
model: "llama-3.3-70b-versatile",
});
// By ISO token (no projectId needed)
await client.keys.updateByToken("iso-your-token", {
model: "llama-3.3-70b-versatile",
});Delete
// By key ID
await client.keys.delete(client.projectId!, key.id);
// By ISO token
await client.keys.deleteByToken("iso-your-token");List all keys
for (const project of await client.projects.list()) {
for (const key of await client.keys.list(project.id)) {
console.log(key.iso_token);
}
}Helper Functions
answer(response) — Extract assistant text
import { answer } from "cortyxia";
const resp = await client.chat.completions.create({ messages: [...] });
console.log(answer(resp)); // Clean string, no JSON diggingCredential Storage
Cortyxia stores credentials in two locations for resilience:
| Location | Path | Priority |
|----------|------|----------|
| Project-local | ./.cortyxia/credentials.json | 1st |
| Machine-global | ~/.cortyxia/credentials.json | 2nd |
Both files are created with 0o600 permissions. A ./.cortyxia/.gitignore with * is auto-generated.
Resolution Order
CORTYXIA_EMAILenv var triggers provisioning / override./.cortyxia/credentials.json(per-project)~/.cortyxia/credentials.json(machine-wide)- Auto-provision if credentials don't exist
Email switching: Change CORTYXIA_EMAIL to switch accounts. Each email has its own isolated project world.
process.env.CORTYXIA_EMAIL = "[email protected]";
const client = await Cortyxia.create();Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| CORTYXIA_EMAIL | Yes (first run) | Email for provisioning |
| API_KEY | No | LLM provider API key (for initialize()) |
| API_PROVIDER | No | Provider name: groq, openai, anthropic, gemini, deepseek, xai |
| API_MODEL | No | Model ID (for initialize()) |
| DEV_MODE | No | true or false (default: false) |
Error Handling
import { Cortyxia, CortyxiaError } from "cortyxia";
try {
const client = await Cortyxia.create();
const key = await client.initialize();
} catch (err) {
if (err instanceof CortyxiaError) {
console.error("Setup failed:", err.message);
}
}FAQ
"What if Cortyxia goes down? Do my prompts break?"
Your prompts don't change. The response shape is identical to OpenAI's. If Cortyxia is unavailable, swap back to your original provider in one line. Your code stays the same.
"Do I need to redesign my app architecture?"
No. If you're already calling chat.completions.create(), you change the import. That's it. Memory happens automatically in the background.
"What about my existing vector DB / RAG pipeline?"
You can keep it. Cortyxia handles the "I talked to this user 3 days ago" memory layer. Your RAG pipeline handles the "here are the docs" layer. They complement each other.
"How much does this cost?"
Generous free tier — try it out or run small projects at no cost. You only pay for your LLM provider usage (Groq, OpenAI, etc.). And because Cortyxia assembles smarter context, you typically use fewer tokens — so your bill goes down, not up.
"Is my data safe?"
- Credentials stored locally with
0o600permissions - Each email has fully isolated project data
- No third-party analytics or telemetry
"Can I use this in production?"
Yes. The core routing and memory layers are battle-tested. Pin your version: npm install [email protected].
License
MIT
