Skip to main content

The Memory Layer for Enterprise AI — persistent memory and 40% token cost reduction for any LLM stack

Project description

Cortyxia Python SDK

The Memory Layer for Enterprise AI — persistent memory and 40% token cost reduction for any LLM stack.

Installation

pip install cortyxia

Requires Python >= 3.9.

Quickstart

Set your email and initialize the client. On first run, Cortyxia auto-provisions a project, API key, and ISO token. No signup form required.

import os
os.environ["CORTYXIA_EMAIL"] = "you@example.com"

from cortyxia import Cortyxia

client = Cortyxia()  # Auto-provisions on first run

# Chat with automatic memory injection
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "What was I working on yesterday?"}]
)
print(response["choices"][0]["message"]["content"])

Credential Storage

Cortyxia stores credentials in two locations for resilience and portability:

Location Path Priority
Project-local ./.cortyxia/credentials.json 1st (highest)
Machine-global ~/.cortyxia/credentials.json 2nd
Environment CORTYXIA_EMAIL Triggers provisioning / override

Both files are created with 0600 permissions. A ./.cortyxia/.gitignore with * is auto-generated to prevent accidental commits.

Resolution Order

  1. If iso_token is passed explicitly to Cortyxia(), it is used directly.
  2. Otherwise, read CORTYXIA_EMAIL from the environment.
  3. Fall back to ./.cortyxia/credentials.json, then ~/.cortyxia/credentials.json.
  4. If credentials exist for the resolved email, use them.
  5. If not, call /v1/auth/provision to create a Supabase auth user, default project, and key.

Credential changes propagate to both files automatically.

Email Switching

Change CORTYXIA_EMAIL to switch accounts. Your data is never deleted — each email has its own isolated project world.

import os
os.environ["CORTYXIA_EMAIL"] = "work@company.com"
client = Cortyxia()  # Provisions or resumes work@company.com

os.environ["CORTYXIA_EMAIL"] = "personal@gmail.com"
client2 = Cortyxia()  # Provisions or resumes personal@gmail.com

If Cortyxia detects another email on the same machine, it stores a soft link and prints a discovery message so you know where your other projects live.

API Reference

Chat

# Non-streaming
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "Hello"}],
    model="gpt-4o",          # optional
    temperature=0.7,         # optional
    max_tokens=256,          # optional
)

# Streaming
for line in client.chat.completions.stream(
    messages=[{"role": "user", "content": "Hello"}]
):
    print(line)

Memory

# Add a memory node
node = client.memory.add(
    content="User prefers Rust over Go",
    tags=["preference", "language"]
)

# Query memory directly
results = client.memory.query("What language does the user prefer?", limit=5)

Projects

# List all projects
projects = client.projects.list()

# Create a new project
project = client.projects.create("Agentic Coding", shared_memory_enabled=True)

# Get / Delete
project = client.projects.get(project["id"])
client.projects.delete(project["id"])

Keys

# Create a standard key
key = client.keys.create(
    project_id=client.project_id,
    label="Production Key",
    provider="OpenAI",
    model="gpt-4o",
)

# Create a developer-mode key (isolated context window for agentic coding)
key = client.keys.create(
    project_id=client.project_id,
    label="Claude Code Agent",
    provider="Anthropic",
    model="claude-sonnet-4-20250514",
    dev_mode=True,
    dev_namespace="isolated",
    recent_window_min=2,
    recent_window_max=8,
)

# Update
client.keys.update(
    project_id=client.project_id,
    key_id=key["id"],
    dev_mode=False,
    recent_window_max=16,
)

# List / Delete
keys = client.keys.list(client.project_id)
client.keys.delete(client.project_id, key["id"])

Self-hosted

# Configure a self-hosted Postgres + Turso backend
client.self_hosted.configure(
    postgres_url="postgresql://user:pass@host/db",
    libsql_url="libsql://your-db.turso.io",
    libsql_auth_token="ey...",
)

# Read / Test / Delete
config = client.self_hosted.get()
result = client.self_hosted.test(postgres_url="...")
client.self_hosted.delete()

Web Dashboard Graduation

SDK-provisioned accounts are fully compatible with the web dashboard. When you sign up on the web with the same email:

  1. The dashboard detects your SDK-provisioned account via /api/auth/check-sdk-user.
  2. You set a password via /api/auth/complete-sdk-signup.
  3. You sign in normally. Your projects, keys, and memory are already there.

Environment Variables

Variable Required Description
CORTYXIA_EMAIL Yes (first run) Email for provisioning and account resolution
CORTYXIA_URL No Base URL of the project service (default: https://api.cortyxia.com)

Error Handling

from cortyxia import Cortyxia, CortyxiaError

try:
    client = Cortyxia()
except CortyxiaError as e:
    print(f"Setup failed: {e}")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cortyxia-0.1.11a1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cortyxia-0.1.11a1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file cortyxia-0.1.11a1.tar.gz.

File metadata

  • Download URL: cortyxia-0.1.11a1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for cortyxia-0.1.11a1.tar.gz
Algorithm Hash digest
SHA256 61ade3392a675c0cd9eb2a6004613779db0d4a76d32c807815385c560170ba5f
MD5 82f39edf01ee7522d896fe9eecc66aca
BLAKE2b-256 8b7ed3904d6b9b3161e579bccfff593596a2161be1e60e38e350147265e91b28

See more details on using hashes here.

File details

Details for the file cortyxia-0.1.11a1-py3-none-any.whl.

File metadata

  • Download URL: cortyxia-0.1.11a1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for cortyxia-0.1.11a1-py3-none-any.whl
Algorithm Hash digest
SHA256 41ba67fd155edd8b981731f229fdc649689db7daf3be302ca8cdb4528587c700
MD5 7c7c5c520f55f80618567a0bb31a15d0
BLAKE2b-256 5b7b85c2a6c9394cb7f2a748d07e716315e2a6207d0db15503e590890a6dd08a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page