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.9.tar.gz (8.5 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.9-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file cortyxia-0.1.9.tar.gz.

File metadata

  • Download URL: cortyxia-0.1.9.tar.gz
  • Upload date:
  • Size: 8.5 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.9.tar.gz
Algorithm Hash digest
SHA256 b918ade0f1fa1623eea75f6dcdcceefd3431711ecc8afc6232240a653c3b087f
MD5 5d4d0c484d1ae6f982b78cdb6bc0b805
BLAKE2b-256 33f3a76316df646145e7953631e42e6259e45c78302fe33808768ad620612de5

See more details on using hashes here.

File details

Details for the file cortyxia-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: cortyxia-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8b511b44b3239b0d982836033f04b09d927350e017e4b10ab5534d2a80200d
MD5 436572f4e5f6fd6af22898c41362bc6b
BLAKE2b-256 ff34113ebc81010b5395388d3b83f33304bc6c1f48b30130975526d7e26594bb

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