Skip to main content

FastAPI server for Z3rno: REST API, authentication, rate limiting, and Celery workers.

Project description

z3rno-server

PyPI License: Apache 2.0 CI

FastAPI REST API server for Z3rno -- wraps z3rno-core engine functions as HTTP endpoints.

Quickstart

Run with Docker Compose

cp .env.example .env   # configure DATABASE_URL, API keys, etc.
docker compose -f docker-compose.dev.yml up

This starts PostgreSQL 17 (with pgvector, Apache AGE), Valkey, the API server on localhost:8000, and a Celery worker.

Store a memory

curl -X POST http://localhost:8000/v1/memories \
  -H "Authorization: Bearer z3rno_sk_test_localdev" \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "agent-1", "content": "User prefers dark mode", "memory_type": "semantic"}'

Recall memories

curl -X POST http://localhost:8000/v1/memories/recall \
  -H "Authorization: Bearer z3rno_sk_test_localdev" \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "agent-1", "query": "What does the user prefer?", "top_k": 5}'

Forget a memory

curl -X POST http://localhost:8000/v1/memories/forget \
  -H "Authorization: Bearer z3rno_sk_test_localdev" \
  -H "Content-Type: application/json" \
  -d '{"memory_id": "<memory-uuid>"}'

For a detailed step-by-step setup, see QUICKSTART.md.

Full documentation: astron-bb4261fd.mintlify.app

API Endpoints

Method Path Description
POST /v1/memories Store a new memory
POST /v1/memories/recall Recall memories by semantic query
POST /v1/memories/forget Soft-delete a memory
GET /v1/audit Query the audit log
POST /v1/sessions Start a new session
POST /v1/sessions/{id}/end End a session
GET /v1/sessions/{id} Get session state
GET /v1/health Health check
GET /v1/ready Readiness check

Configuration

All configuration is via environment variables:

Variable Description Default
DATABASE_URL PostgreSQL connection string (asyncpg) required
VALKEY_URL Valkey URL (falls back to REDIS_URL) redis://localhost:6379/0
Z3RNO_API_KEY API key for authentication required
EMBEDDING_MODEL LiteLLM embedding model name text-embedding-3-small
OPENAI_API_KEY OpenAI API key (for embeddings) --
LOG_LEVEL Logging level INFO
CORS_ORIGINS Allowed CORS origins (comma-separated) --

OpenAPI Documentation

When running locally, interactive API docs are available at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Development

uv sync --dev
uv run ruff check .
uv run mypy .
uv run pytest

See CONTRIBUTING.md for the full workflow.

License

Apache 2.0 -- see LICENSE.

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

z3rno_server-0.9.0.tar.gz (374.5 kB view details)

Uploaded Source

Built Distribution

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

z3rno_server-0.9.0-py3-none-any.whl (72.7 kB view details)

Uploaded Python 3

File details

Details for the file z3rno_server-0.9.0.tar.gz.

File metadata

  • Download URL: z3rno_server-0.9.0.tar.gz
  • Upload date:
  • Size: 374.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for z3rno_server-0.9.0.tar.gz
Algorithm Hash digest
SHA256 cb6a9cd62f9550b8b6a326d4818dacd2a297d38f80e522c4476f50bcd4965a29
MD5 f2ed0d103f819b4e81f561e31923f069
BLAKE2b-256 3b40cf5643eea5ab2a42c6e0ad66f90a670f555100d609114a5d52f785ad886d

See more details on using hashes here.

File details

Details for the file z3rno_server-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: z3rno_server-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 72.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for z3rno_server-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8dbd4bd236f2f6b40c6c218f59f9b2873aae27f5f7ebd052626d379800d6c184
MD5 165d4261c8787e6b792c43ff868cbb7f
BLAKE2b-256 86fe7f8b90e07bccb5da35c067944a834b0bd2583d90b657a151beb4467dae0f

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