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.10.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.10-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cortyxia-0.1.10.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.10.tar.gz
Algorithm Hash digest
SHA256 220fe9dc28c1d1f81cd4f20d4bbb36ce15240316436f7d9c2db811cf49764362
MD5 2a7e08ebbfbb04e42667accc4e7cac96
BLAKE2b-256 99ac90c73c908c6e3ea7eba72e016812e4c6ea06abd6ff2011106a32876785a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cortyxia-0.1.10-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.10-py3-none-any.whl
Algorithm Hash digest
SHA256 afa9e69f7d03c5676dbcbbd0d40ced945e5b8a183b216156b629d9d5b17ea2e7
MD5 8a9cb619b92cdbb4ea8402e8962e4598
BLAKE2b-256 869edba9ccfca054e4f271f5b71c3e220e5ccd075135d834d30d2839d5a10e82

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